【发布时间】:2018-03-06 02:24:57
【问题描述】:
我正在用 Beautiful soup 解析某个网页,试图检索 h3 标签内的所有链接:
page = = requests.get(https://www....)
soup = BeautifulSoup(page.text, "html.parser")
links = []
for item in soup.find_all('h3'):
links.append(item.a['href']
但是,找到的链接与页面中的链接不同。例如,当页面中存在链接http://www.estense.com/?p=116872 时,Beautiful soup 返回http://www.estense.com/%3Fp%3D116872,替换“?” '%3F' 和 '=' 和 %3D。这是为什么呢?
谢谢。
【问题讨论】:
-
这是 url 转义。但我无法重现此问题。你用的是什么版本的 Python?
-
我使用 Python 3.5.3。
标签: web-scraping character-encoding beautifulsoup