html - Python2 BeautifulSoup 提取網(wǎng)頁中的表格數(shù)據(jù)及連接
問題描述
網(wǎng)址:http://quote.eastmoney.com/ce...要做的是提取網(wǎng)頁中的表格數(shù)據(jù)(如:板塊名稱,及相應(yīng)鏈接下的所有個(gè)股,依然是個(gè)表格)
暫時(shí)只寫了這些代碼:import urllib2from bs4 import BeautifulSoup
url=’http://quote.eastmoney.com/ce...’
req=urllib2.Request.(url)page=urllib2.urlopen(req)
soup=BeautifulSoup(page)table = soup.find('table')
但是table里面沒有內(nèi)容,也就是完全沒找到,這是怎么回事啊。po是小白,希望大神們可以多多指教,謝謝!
問題解答
回答1:因?yàn)槭钱惒郊虞d,數(shù)據(jù)在這里http://nufm.dfcfw.com/EM_Fina...
# coding:utf-8import requestsr = requests.get(’http://nufm.dfcfw.com/EM_Finance2014NumericApplication/JS.aspx?type=CT&cmd=C._BKGN&sty=FPGBKI&st=c&sr=-1&p=1&ps=5000&token=7bc05d0d4c3c22ef9fca8c2a912d779c&v=0.12043042036331286’)data = [_.decode(’utf-8’).split(’,’) for _ in eval(r.text)]url = ’http://quote.eastmoney.com/center/list.html#28003{}_0_2’lst = [(url.format(_[1].replace(’BK0’, ’’)), _[2]) for _ in data]print lst
相關(guān)文章:
1. php - mysql 模糊搜索問題2. html - 爬蟲時(shí)出現(xiàn)“DNS lookup failed”,打開網(wǎng)頁卻沒問題,這是什么情況?3. javascript - 在 vue里面用import引入js文件,結(jié)果為undefined4. php工具箱配置第二個(gè)vhost主機(jī)時(shí)不生效,報(bào)錯(cuò)You don’t have permission5. php - 微信開發(fā)驗(yàn)證服務(wù)器有效性6. 求救一下,用新版的phpstudy,數(shù)據(jù)庫過段時(shí)間會(huì)消失是什么情況?7. [python2]local variable referenced before assignment問題8. javascript - js setTimeout在雙重for循環(huán)中如何使用?9. javascript - 我的站點(diǎn)貌似被別人克隆了, google 搜索特定文章,除了域名不一樣,其他的都一樣,如何解決?10. javascript - 求幫助 , ATOM不顯示界面!!!!
