html - Python2 BeautifulSoup 提取网页中的表格数据及连接

 你一句话就逼我撤退 发布于 2022-10-27 05:31

网址:http://quote.eastmoney.com/ce...
要做的是提取网页中的表格数据(如:板块名称,及相应链接下的所有个股,依然是个表格)

暂时只写了这些代码:
import urllib2
from 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-8
    
    import requests
    
    r = 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
    2022-11-12 01:40 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有