用Python requests beautifulSoup 获取并显示中文信息
使用requests来打开URL地址,获取编码为utf-8
得到的标签或信息在显示时用gb18030来显示。
book_page = requests.get("https://book.douban.com/subject/26906797/", )
print(book_page.status_code)
status_code = book_page.status_code
#if status_code == 200:
# print("The content is " + book_page.content)
bs_page = BeautifulSoup(book_page.content, features='lxml', from_encoding='utf8')
print(u"Article_info is {}")
article_info = bs_page.find_all(id='info')
for article in article_info:
article.encode('gb18030')
print(article.text)
posted on 2019-08-03 12:16 ShannonHan 阅读(769) 评论(0) 收藏 举报
浙公网安备 33010602011771号