Thanks Snipssat. Had a look at the tutorial but this part did not work (get error about syntax in HTML):
html = '''\
insert html
'''
<html> # Get error here
<head>
<title>My Site</title>
</head>
<body>
<title>First chapter</title>
<p>Page1</p>
<p>Page2</p>
</body>
</html>
Python Code: (Double-click to select all)
1
2
3
4
5
6
7
from bs4 import BeautifulSoup
soup = BeautifulSoup(html, 'html.parser')
print(soup.find('title'))
print(soup.find_all('title'))
#--> <title>My Site</title>
#--> [<title>My Site</title>, <title>First chapter</title>]
Thanks Wavic. Tried it but get error - forgive my ignorance about this.
html = '''\
insert html
'''
<html> # Get error here
<head>
<title>My Site</title>
</head>
<body>
<title>First chapter</title>
<p>Page1</p>
<p>Page2</p>
</body>
</html>
Python Code: (Double-click to select all)
1
2
3
4
5
6
7
from bs4 import BeautifulSoup
soup = BeautifulSoup(html, 'html.parser')
print(soup.find('title'))
print(soup.find_all('title'))
#--> <title>My Site</title>
#--> [<title>My Site</title>, <title>First chapter</title>]
Thanks Wavic. Tried it but get error - forgive my ignorance about this.