【发布时间】:2021-04-05 00:24:53
【问题描述】:
我想用 Python 抓取这个页面:https://statusinvest.com.br/acoes/proventos/ibovespa。
使用此代码:
import requests
from bs4 import BeautifulSoup as bs
URL = "https://statusinvest.com.br/acoes/proventos/ibovespa"
page = 1
req = requests.get(URL+str(page))
soup = bs(req.text, 'html.parser')
container = soup.find('div', attrs={'class','list'})
dividends = container.find('a')
for dividend in dividends:
links = dividend.find_all('a')
print(links)
但它不返回任何东西。
有人可以帮帮我吗?
【问题讨论】:
-
欢迎来到 SO!请参阅:Why is “Can someone help me?” not an actual question?。你想在这里获取什么数据?几乎可以肯定,您想要的数据是通过 JS 注入的。见Web-scraping JavaScript page with Python
-
你看过这个页面的源代码吗?数据全部存储在一个名为
result的隐藏<input>标记中。 Javascript 代码动态扩展它以创建页面。由于您没有执行 Javascript,因此您不会看到它。但是,您也许可以通过阅读<input>标签获得您想要的。
标签: python html web-scraping