【发布时间】:2019-07-21 05:53:22
【问题描述】:
我接受获取 h2-tag 文本,但它显示“无”。它存在。 我试图改变 page.content 'html.parser to lxml' 等等。还是不行。
from bs4 import BeautifulSoup
import requests
headers = {"User-agent":"Mozilla/5.0 (X11; Linux x86_64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80
Safari/537.36"}
url = 'http://www.unitedstateszipcodes.org/54115'
page = requests.get(url,headers=headers).text
soup = BeautifulSoup(page, 'html.parser')
div = soup.find('div', class_='col-xs-12').h2
print(div)
我试图在 xml 中更改页面内容,之后它显示elif len(markup) <= 256 and (
TypeError: object of type 'Response' has no len()
【问题讨论】:
-
您能更好地解释一下您要做什么吗?
.h2是干什么用的?
标签: python html beautifulsoup