我试图从一个股票网站上搜集数据,但问题是表的内容是隐藏的。该网站是http://www.moneycontrol.com/stocks/histstock.php
1.Select Index
2.Select S&P BSE MIDCAP
3.Filter data from Jan 2019 to Jan 2020 to get to the final page
4.I want to scrape the table contents of this page
这就是我尝试用的汤
import requests
from bs4 import BeautifulSoup
link='http://www.moneycontrol.com/stocks/hist_index_result.php?indian_indices=25'
html=requests.get(link)
html.status_code #200
raw=html.content
soup=BeautifulSoup(raw,'html.parser') #have tried with xml and html5lib
soup.find_all('table',{'class':'tblchart'})
#output
[<table border="0" cellpadding="0" cellspacing="0" class="tblchart">
</table>]
我也尝试过使用硒,但结果是一样的
我很难获得信息
如有任何建议、回答或是朝着正确的方向轻推,我们将不胜感激
仅使用
BeautifulSoup
的解决方案。数据是通过Ajax动态加载的,但您只需使用requests
模块即可模拟请求:印刷品:
好了,伙计们,我实际上用硒解决了这个问题,我必须更新我的硒包,它就像一个符咒
我是这样做的:
相关问题 更多 >
编程相关推荐