Apr-25-2017, 12:08 AM
(Apr-24-2017, 10:34 PM)kendias Wrote: Thanks Snipssat. Had a look at the tutorial but this part did not work (get error about syntax in HTML)Use code tag.
Use like this.
from bs4 import BeautifulSoup html = '''\ <html> <head> <title>My Site</title> </head> <body> <title>First chapter</title> <p>Page1</p> <p>Page2</p> </body> </html>''' soup = BeautifulSoup(html, 'html.parser') print(soup.find('title')) print(soup.find_all('title'))
Output:<title>My Site</title>
[<title>My Site</title>, <title>First chapter</title>]
text
to get contend.>>> soup.find('title').text u'My Site'