我正在努力清理网站:
http://finance.sina.com.cn/futures/quotes/I0.shtml?from=wap
捕捉中国铁矿石的变化:
刮完之后,我搜索标签,发现所有东西都是空的
我正在使用:
url2 = 'http://finance.sina.com.cn/futures/quotes/I0.shtml?from=wap'
html2 = urlopen(url2)
bs2 = BeautifulSoup(html2, 'lxml')
print(bs2.title)
print(bs2.find_all('span', class_ = 'amt'))
输出:
<title>铁矿石2005(I0)期货行情,新闻,报价_新浪财经_新浪网</title>
[<span class="amt">--</span>, <span class="amt">--</span>, <span class="amt">--</span>, <span class="amt">--</span>, <span class="amt">--</span>, <span class="amt">--</span>, <span class="amt">--</span>, <span class="amt">--</span>, <span class="amt">--</span>, <span class="amt">--</span>, <span class="amt">--</span>, <span class="amt">--</span>, <span class="amt">--</span>, <span class="amt">--</span>, <span class="amt">--</span>, <span class="amt">--</span>,.....
我已经打开浏览器控制台,查看该站点正在调用的其他页面,并发现以下两个页面:
http://hq.sinajs.cn/?_=1584562106303/&list=nf_I0
但没有发现资产的变化。。。。。(+0.16%)
你能帮我解决这个问题吗
我认为这是因为
0.16%
在网页首次加载时并不存在它是由javascript动态生成的,据我所知
BeautifulSoup
无法处理这种情况你可以在这个link中找到与这个问题类似的答案
我建议使用硒。虽然速度较慢,但会起作用 见https://www.selenium.dev/
相关问题 更多 >
编程相关推荐