【发布时间】:2020-03-07 07:41:11
【问题描述】:
from bs4 import BeautifulSoup
from urllib import request
import csv
# adding a correct user agent
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36'}
#The url to be scraped
company_page = 'https://www.goodreads.com/list/show/6.Best_Books_of_the_20th_Century?'
#opening the page
page_request = request.Request(company_page, headers=headers)
page = request.urlopen(page_request)
#parse the html using beautiful soup
html_content = BeautifulSoup(page, 'html.parser')
#Parsing some of the title elements
title = html_content.find('div',id='shell')
print(title)
【问题讨论】:
-
id="shell"引用了哪些信息? -
如果您的问题得到解决,请将答案标记为已接受,以便其他人可以看到您的问题已得到解答。
标签: python web web-scraping beautifulsoup