Python中文
首页
教程
问答
标签
搜索
登录
注册
美丽之声:刮蒸汽愿望清单游戏。findAll不返回嵌套divs可见检查
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>所以我想用beautifulsoup从我的steam愿望列表中删除游戏。理想情况下,我想游戏的名称,链接到蒸汽商店网页的游戏和目前上市的价格。问题是,当我调用<code>soup.find_all("div", {"class": "wishlist_row"})</code>时,它返回一个空列表,尽管我能够在inspector中看到每个游戏的愿望列表上都应该有几个div。以下是我当前代码的精简版本:</p> <pre><code>from bs4 import BeautifulSoup import requests profile_id = "id/Zorro4" url_base = "https://store.steampowered.com/wishlist/" r = requests.get(url_base + profile_id + "#sort=order", headers=header) data = r.text soup = BeautifulSoup(data, features="lxml") # find divs containing information about game and steam price divs = soup.findAll("div", {"class": "wishlist_row"}) print(divs) >>> [] </code></pre> <p>如果我转到<a href="https://store.steampowered.com/wishlist/id/zorro4/#sort=order" rel="nofollow noreferrer">https://store.steampowered.com/wishlist/id/zorro4/#sort=order</a>,我可以在检查器中清楚地看到这些div 我试过了</p> <ul> <li>使用html.parser语法分析器代替lxml</li> <li>欺骗用户代理/头</li> <li>尝试改用<code>.find("div", {"class": "wishlist_row"})</code></li> <li>通过这些线索 <ul> <li><a href="https://stackoverflow.com/questions/42593383/parsing-nested-divs-with-beautifulsoup">Parsing nested divs with BeautifulSoup</a></li> <li><a href="https://stackoverflow.com/questions/2136267/beautiful-soup-and-extracting-a-div-and-its-contents-by-id">Beautiful Soup and extracting a div and its contents by ID</a></li> <li><a href="https://stackoverflow.com/questions/42097894/beautifulsoup-cant-find-required-div">BeautifulSoup can't find required div</a></li> </ul></li> </ul> <p>我注意到一些奇怪的事情可能有助于解决这个问题,但我不知道该怎么办。你知道吗</p> <pre><code>soup.find(id="wishlist_ctn") # The div which should contain all the wishlist_row divs >>> <div id="wishlist_ctn">\n</div> </code></pre> <p>据我所知,这应该返回<code><div id="wishlist_ctn">...</div></code>,因为div包含更多嵌套的div(我正在寻找的那些)。我不知道为什么它只返回换行符。这几乎就好像当你把愿望清单上的东西都弄丢了一样。任何帮助都将不胜感激,过去几天我一直试图解决这个问题,但都没有成功。你知道吗</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>问题是wishlist实际上是由AJAX请求填充的。靓汤不具备这种功能。你需要一个网络驱动程序。幸运的是,这里的捷径是只使用为wishlist发出的API调用并解析JSON响应。在这种情况下,请求是:</p> <p><code>https://store.steampowered.com/wishlist/profiles/76561198068616380/wishlistdata/?p=0</code></p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
plt.savefig不会覆盖现有文件
6 回答
plt.savefig不保存图像
9 回答
plt.savefig在jupyter笔记本中不起作用
9 回答
plt.savefig在从另一个fi调用时停止工作
4 回答
plt.savefig在调用plt.show之前保存空数字
8 回答
plt.save不创建png文件
5 回答
plt.scatter overlay分类数据帧列
7 回答
Plt.Scatter:如何添加title、xlabel和ylab
9 回答
plt.scatter()绘图与Matplotlib中的plt.plot()绘图类似
1 回答
plt.scatter错误'NoneType'对象在成功运行后没有属性'sqrt'
8 回答
plt.set_title()中的标题字符串有误
6 回答
plt.show()
9 回答
plt.show()不在Jupyter笔记本上渲染任何内容
10 回答
plt.show()不打印plt.plot only plt.scatter
1 回答
plt.show()不显示三维散射图像
6 回答
plt.show()不显示任何内容
9 回答
plt.show()不显示数据,而是保留它供下一个图表使用(spyder)
8 回答
plt.show()使终端挂起
3 回答
plt.show()无法使用此代码
7 回答
plt.show()没有打开新的图形风
9 回答