我尝试过无数种不同的方法,但我不明白为什么Beautifulsoup和我所有的前任一样不可预测
我只是想把一个表复制到一个数据框中。桌子上大约有280行
以下是网址:
https://www.brilliantearth.com/design-your-own-engagement-ring/?sid=3755106&dc=
以下是我的部分代码不起作用:
with requests.Session() as s:
url = "https://www.brilliantearth.com/design-your-own-engagement-ring/?sid=3755106&dc="
r = s.get(url, headers=req_headers)
#add contents of urls to soup variable from each url
soup = BeautifulSoup(r.content, 'lxml')
rows = soup.find_all("div", {"id": "diamonds_search_table"})
rows
以下是url中的表格所在位置:
下一步我能试试什么
数据通过JavaScript动态加载。您可以使用
requests
模块来模拟它例如:
印刷品:
您可以使用
selenium
解析html
。您可以尝试:您将获得如下所示的所有行:
相关问题 更多 >
编程相关推荐