html - Python2 BeautifulSoup 提取網(wǎng)頁中的表格數(shù)據(jù)及連接
問題描述
網(wǎng)址:http://quote.eastmoney.com/ce...要做的是提取網(wǎng)頁中的表格數(shù)據(jù)(如:板塊名稱,及相應(yīng)鏈接下的所有個股,依然是個表格)
暫時只寫了這些代碼: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:因為是異步加載,數(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. mysql優(yōu)化 - mysql count(id)查詢速度如何優(yōu)化?2. python - django 里自定義的 login 方法,如何使用 login_required()3. javascript - git clone 下來的項目 想在本地運行 npm run install 報錯4. node.js - node_moduls太多了5. mysql主從 - 請教下mysql 主動-被動模式的雙主配置 和 主從配置在應(yīng)用上有什么區(qū)別?6. angular.js - 不適用其他構(gòu)建工具,怎么搭建angular1項目7. 主從備份 - 跪求mysql 高可用主從方案8. android-studio - Android 動態(tài)壁紙LayoutParams問題9. python如何不改動文件的情況下修改文件的 修改日期10. 在Java中System.out.println 只能在method中使用嗎?
