【发布时间】:2019-11-10 11:54:36
【问题描述】:
我已经启动并运行了 Beautifulsoup,但是在解析网站的 html 时,我的目标是“汤”对象似乎没有显示 div 中的 div 等等。我试图从一个很深的网站获取项目详细信息。查看实际站点 html 时,我可以看到我想要到达的层,但汤只显示父 div,如下所示:
<div id="react-views-container"></div>
如何进入这个 div?
到目前为止,我的代码如下所示:
import urllib.request
import requests
from bs4 import BeautifulSoup
#setting up connection and testing by printig html
proxy_support = urllib.request.ProxyHandler("proxies_hidden_for_privacy")
opener = urllib.request.build_opener(proxy_support)
urllib.request.install_opener(opener)
html = urllib.request.urlopen("target_website").read()
print (html)
soup = BeautifulSoup(html)
div = soup.find(id="react-views-container")
【问题讨论】:
-
您能否分享您要废弃的网站以及您正在查看的
div标签。 ? -
是的,我将多次这样做,但网站是 instacart.com。我正在尝试查看某些搜索词返回了哪些项目。一个具体的例子是这个搜索樱桃instacart.com/store/the-fresh-market/search_v3/cherry div 我提到“react-views-container”似乎包含返回项目的网格。我想获得似乎在中的返回项目的名称好的。我正在检查它。很快就会回复你mitch:请将这些问题详细信息移到问题正文中,而不是评论。评论无法编入索引或搜索,它们是短暂的,最终可能会被删除。
标签: python python-3.x web-scraping beautifulsoup