2017-03-16 137 views
0

我想用bs4抓this page,我想知道我該如何刮EUR/USD,price changeprice %網絡抓取cnbc.com

我是很新的這一點,所以這是我到目前爲止有:

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) 
+0

問題是什麼?有些東西不能按預期工作,以至於無法繼續,或者您是否要求我們爲您編寫實際的代碼? –

+0

我想你需要使用requests.get(url,stream = True),然後分析代碼。看看[Bodycontent工作流程](http://docs.python-requests.org/en/master/user/advanced/#body-content-workflow) – GeoStoneMarten

+0

我想我的問題是 - 是否有可能做到?通過源代碼,看起來價格,價格變化和%變化是圖像?我可能(可能是)完全錯誤 – qorka

回答