【发布时间】:2018-12-25 15:09:27
【问题描述】:
想拉出此网页上产品的 href 链接。该代码提取除页面上列出的产品之外的所有 href。
from bs4 import BeautifulSoup
import requests
url = "https://www.neb.com/search#t=_483FEC15-900D-4CF1-B514-1B921DD055BA&sort=%40ftitle51880%20ascending"
response = requests.get(url)
data = response.text
soup = BeautifulSoup(data, 'lxml')
tags = soup.find_all('a')
for tag in tags:
print(tag.get('href'))
【问题讨论】:
-
快速浏览一下网络检查器告诉我,该记录集中有 13323 条记录。此外,结果是在客户端从 json 有效负载格式化的,所以我想你会对结构化格式有更好的运气。无论哪种方式,您都必须处理分页。
标签: python beautifulsoup href