我试图理解刮取的逻辑以及如何找到搜索到的数据。 我正在尝试浏览以下网站:
当我使用下面的代码时:
import requests
from bs4 import BeautifulSoup
page = requests.get('https://fr.finance.yahoo.com/')
soup = BeautifulSoup(page.text,'html.parser')
y = soup.find(id="market-summary")
print(y)
结果就是我想要的
但是,当我尝试使用代码复制结果时:
import requests
from bs4 import BeautifulSoup
page = requests.get('https://fr.finance.yahoo.com/')
soup = BeautifulSoup(page.text,'html.parser')
x = soup.find("div", class_= 'Whs(nw) D(ib) Bgc($lv2BgColor) W(100%) Bxz(bb)')
print(x)
结果我得到了“无”。 有人能解释一下我做错了什么吗?如何使用“class”作为标记来查找我要查找的数据
尝试:
相关问题 更多 >
编程相关推荐