Click here for Preparation for Beautiful Soup
I haven't been motivated recently, so I decided to write it for the time being. It ’s really the foundation of the foundation, so it ’s not bad.
For now, let's run Beautiful Soup.
from urllib.request import urlopen
from bs4 import BeautifulSoup
#Page to get
html = urlopen('http://www.pythonscraping.com/pages/page1.html')
bs = BeautifulSoup(html.read(), 'html.parser')
#Returns the h1 tag
print(bs.h1)
2nd line
from bs4 import BeautifulSoup
Import Beautiful Soup in the part. The execution result is as follows.
http://www.pythonscraping.com/pages/page1.html You can see that only the h1 tag on the above page can be obtained.
Next time, I will post with proper content.
Web scraping with Python (O'Reilly Japan)
Recommended Posts