【发布时间】:2017-03-16 18:18:00
【问题描述】:
我正在尝试使用 bs4 抓取 this page,我想知道如何抓取 EUR/USD、price change 和 price %?
我对此很陌生,所以这就是我目前所拥有的一切:
import requests
from bs4 import BeautifulSoup
url = 'http://www.cnbc.com/pre-markets/'
source_code = requests.get(url).text
soup = BeautifulSoup(source_code, 'lxml')
for r in soup.find_all('td', {'class': 'first text'}):
print(r)
【问题讨论】:
-
有什么问题?是不是有什么事情没有按预期工作,所以您无法继续,还是您要求我们为您编写实际代码?
-
我认为您需要使用 requests.get(url, stream=True) 并在之后分析代码。看Bodycontent workflow
-
我想我的问题是——有可能吗?通过源代码看,价格、价格变化和百分比变化似乎是图像?我可能(并且可能)完全错了
-
@MadPhysicist 在从 cnbc.com/pre-markets 提取整个文本后,我注意到信息(欧元/美元)没有显示 - 不要认为可以刮掉..跨度>
标签: python web web-scraping