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. javascript - 關(guān)于<a>元素與<input>元素的JS事件運(yùn)行問題2. css3 - 純css實(shí)現(xiàn)點(diǎn)擊特效3. MySQL中的enum類型有什么優(yōu)點(diǎn)?4. android下css3動(dòng)畫非常卡,GPU也不差啊5. java - 為什么第一個(gè)線程已經(jīng)釋放了鎖,第二個(gè)線程卻不行?6. mysql - 記得以前在哪里看過一個(gè)估算時(shí)間的網(wǎng)站7. javascript - vscode alt+shift+f 格式化js代碼,通不過eslint的代碼風(fēng)格檢查怎么辦。。。8. 大家好,我想請(qǐng)問一下怎么做搜索欄能夠搜索到自己網(wǎng)站的內(nèi)容。9. python - 啟動(dòng)Eric6時(shí)報(bào)錯(cuò):’qscintilla_zh_CN’ could not be loaded10. mysql - 查詢字段做了索引為什么不起效,還有查詢一個(gè)月的時(shí)候數(shù)據(jù)都是全部出來的,如果分拆3次的話就沒問題,為什么呢。
