我正在尝试使用BS4从雅虎财经的期权合约页面中获取数据。下面是我的测试链接和我为获取所需信息而编写的代码
def get_option_volume(url):
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")
value = soup.findAll(attrs={"data-reactid":"84"})
for i in value:
print(i)
get_option_volume("https://finance.yahoo.com/quote/AAPL200221C00320000?p=AAPL200221C00320000")
当我查看页面的HTML数据时,我看到我想要的数据有一个属性为datareact id=84的标记
但是当我运行代码时,我得到的值是一个空变量。我哪里做错了?我查看了文档和其他stackoverflow帖子,但无法找出我的程序失败的地方。它适用于其他随机网站,但不适用于此网站
目前没有回答
相关问题 更多 >
编程相关推荐