Python 在页面上拖动后清空html标记
我正在努力清理网站: 捕捉中国铁矿石的变化: 刮完之后,我搜索标签,发现所有东西都是空的 我正在使用:Python 在页面上拖动后清空html标记,python,html,web-scraping,Python,Html,Web Scraping,我正在努力清理网站: 捕捉中国铁矿石的变化: 刮完之后,我搜索标签,发现所有东西都是空的 我正在使用: 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')) 输出: <
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>,.....
铁矿石2005(I0)期货行情,新闻,报价_新浪财经_新浪网
[--, --, --, --, --, --, --, --, --, --, --, --, --, --, --, --,.....
我已经打开浏览器控制台,查看该站点正在调用的其他页面,并发现以下两个页面:
但没有发现资产的变化……(+0.16%)
你能帮我解决这个问题吗?我想那是因为
0.16%
在网页首次加载时并不存在
它是由javascript动态生成的,据我所知,BeautifulSoup
无法处理这种情况
在这篇文章中,你可以看到与这个问题类似的答案。我建议你使用硒。它速度较慢,但会起作用
Seen selenium docs我认为这是因为当网页第一次加载时,
0.16%
并不存在,它是由javascript动态生成的,据我所知,BeautifulSoup
无法处理这种情况。你可以看看这个问题的答案-->把它作为一个答案,它解决了我的问题太好了!我很高兴听到这个消息T