【发布时间】:2021-12-20 18:39:11
【问题描述】:
我正在尝试从 Yahoo! 获取 Gold 股票代码财务。
from bs4 import BeautifulSoup
import requests, lxml
response = requests.get('https://finance.yahoo.com/quote/GC=F?p=GC=F')
soup = BeautifulSoup(response.text, 'lxml')
gold_price = soup.findAll("div", class_='My(6px) Pos(r) smartphone_Mt(6px)')[2].find_all('p').text
每当我运行它时,它都会返回:list index out of range。
当我执行print(len(ssoup)) 时,它会返回4。
有什么想法吗? 谢谢。
【问题讨论】:
标签: python web-scraping beautifulsoup yahoo-finance