html - Python2 BeautifulSoup 提取网页中的表格数据及连接
问题描述
网址:http://quote.eastmoney.com/ce...要做的是提取网页中的表格数据(如:板块名称,及相应链接下的所有个股,依然是个表格)
暂时只写了这些代码: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里面没有内容,也就是完全没找到,这是怎么回事啊。po是小白,希望大神们可以多多指教,谢谢!
问题解答
回答1:因为是异步加载,数据在这里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
相关文章:
1. html5 - 移动端UC浏览器兼容问题2. 在windows下安装docker Toolbox 启动Docker Quickstart Terminal 失败!3. javascript - js 对象深拷贝和赋值4. mac连接阿里云docker集群,已经卡了2天了,求问?5. docker镜像无法删除,请求解决办法。6. PHP单例模式7. docker 下面创建的IMAGE 他们的 ID 一样?这个是怎么回事????8. angular.js - 用angular2-cli打包项目之后,跳转路由刷新会报404的错误9. node.js - 来帮我捋一下node中fs模块watch实现原理10. 老师,你这两条斜杠的是怎么注释的?