Python 东方财富网-股市行情数据抓取
东方财富网 股市行情数据抓取;
http://quote.eastmoney.com/center/gridlist.html#hs_a_board
请求数据未入库处理,其中数据只存入数据文本,未做存入数据库处理
请求样例数据结果:
jQuery112406092635132097686_1569674756779({"rc":0,"rt":6,"svr":181233083,"lt":1,"full":1,"data":{"total":3815,"diff":[{"f1":2,"f2":55.15,"f3":43.99,"f4":16.85,"f5":210,"f6":1145060.0,"f7":23.99,"f8":0.1,"f9":31.72,"f10":"-","f11":0.0,"f12":"300792","f13":0,"f14":"N壹网","f15":55.15,"f16":45.96,"f17":45.96,"f18":38.3,"f20":4412000000,"f21":1103000000,"f22":0.0,"f23":3.91,"f24":0.0,"f25":43.99,"f62":1008914.0,"f115":24.39,"f128":"-","f140":"-","f141":"-","f136":"-","f152":2},{"f1":2,"f2":81.8,"f3":17.04,"f4":11.91,"f5":53085,"f6":409394064.0,"f7":18.39,"f8":29.56,"f9":-1402.53,"f10":1.31,"f11":0.0,"f12":"688333","f13":1,"f14":"铂力特","f15":82.1,"f16":69.25,"f17":71.0,"f18":69.89,"f20":6544000000,"f21":1469082028,"f22":0.0,"f23":6.59,"f24":34.1,"f25":34.1,"f62":37917359.0,"f115":118.49,"f128":"-","f140":"-","f141":"-","f136":"-","f152":2},{"f1":2,"f2":3.17,"f3":10.07,"f4":0.29,"f5":198417,"f6":62805298.0,"f7":10.42,"f8":4.79,"f9":-33.29,"f10":4.39,"f11":0.0,"f12":"002504","f13":0,"f14":"弘高创意","f15":3.17,"f16":2.87,"f17":2.87,"f18":2.88,"f20":3251787658,"f21":1314120238,"f22":0.0,"f23":3.58,"f24":-8.65,"f25":-13.15,"f62":22200837.0,"f115":-62.84,"f128":"-","f140":"-","f141":"-","f136":"-","f152":2},{"f1":2,"f2":5.91,"f3":10.06,"f4":0.54,"f5":138445,"f6":80763569.0,"f7":9.87,"f8":1.88,"f9":-157.89,"f10":4.3,"f11":0.0,"f12":"002699","f13":0,"f14":"美盛文化","f15":5.91,"f16":5.38,"f17":5.38,"f18":5.37,"f20":5375574805,"f21":4342243686,"f22":0.0,"f23":1.78,"f24":-2.96,"f25":7.85,"f62":23301055.0,"f115":-18.3,"f128":"-","f140":"-","f141":"-","f136":"-","f152":2},{"f1":2,"f2":13.04,"f3":10.04,"f4":1.19,"f5":268206,"f6":343357472.0,"f7":10.13,"f8":6.05,"f9":29.99,"f10":1.73,"f11":0.0,"f12":"600363","f13":1,"f14":"联创光电","f15":13.04,"f16":11.84,"f17":11.85,"f18":11.85,"f20":5782936820,"f21":5782936820,"f22":0.0,"f23":2.3,"f24":10.32,"f25":64.03,"f62":11762884.0,"f115":27.63,"f128":"-","f140":"-","f141":"-","f136":"-","f152":2},{"f1":2,"f2":18.65,"f3":10.03,"f4":1.7,"f5":136079,"f6":250388102.0,"f7":6.78,"f8":27.05,"f9":62.3,"f10":1.45,"f11":0.0,"f12":"603933","f13":1,"f14":"睿能科技","f15":18.65,"f16":17.5,"f17":18.65,"f18":16.95,"f20":3752999180,"f21":938341180,"f22":0.0,"f23":3.62,"f24":37.54,"f25":41.72,"f62":36024950.0,"f115":57.88,"f128":"-","f140":"-","f141":"-","f136":"-","f152":2},{"f1":2,"f2":7.46,"f3":10.03,"f4":0.68,"f5":136982,"f6":98801261.0,"f7":9.59,"f8":3.42,"f9":95.92,"f10":1.39,"f11":0.0,"f12":"002581","f13":0,"f14":"未名医药","f15":7.46,"f16":6.81,"f17":6.85,"f18":6.78,"f20":4921627472,"f21":2989902061,"f22":0.0,"f23":1.77,"f24":5.97,"f25":15.48,"f62":8171310.0,"f115":-64.99,"f128":"-","f140":"-","f141":"-","f136":"-","f152":2},{"f1":2,"f2":8.23,"f3":10.03,"f4":0.75,"f5":820036,"f6":656416272.0,"f7":9.09,"f8":3.43,"f9":26.87,"f10":1.11,"f11":0.0,"f12":"002152","f13":0,"f14":"广电运通","f15":8.23,"f16":7.55,"f17":7.55,"f18":7.48,"f20":19826020217,"f21":19697356808,"f22":0.0,"f23":2.25,"f24":21.57,"f25":49.91,"f62":89361087.0,"f115":28.52,"f128":"-","f140":"-","f141":"-","f136":"-","f152":2},{"f1":2,"f2":9.66,"f3":10.02,"f4":0.88,"f5":393672,"f6":374552944.0,"f7":10.59,"f8":6.51,"f9":27.84,"f10":2.56,"f11":0.0,"f12":"002326","f13":0,"f14":"永太科技","f15":9.66,"f16":8.73,"f17":8.78,"f18":8.78,"f20":7896692841,"f21":5846040548,"f22":0.0,"f23":2.72,"f24":13.11,"f25":41.23,"f62":66536824.0,"f115":35.7,"f128":"-","f140":"-","f141":"-","f136":"-","f152":2},{"f1":2,"f2":24.26,"f3":10.02,"f4":2.21,"f5":60516,"f6":142278510.0,"f7":8.84,"f8":15.08,"f9":78.85,"f10":0.82,"f11":0.0,"f12":"300576","f13":0,"f14":"容大感光","f15":24.26,"f16":22.31,"f17":22.45,"f18":22.05,"f20":2911200000,"f21":973278328,"f22":0.0,"f23":6.55,"f24":26.35,"f25":75.42,"f62":11872820.0,"f115":70.41,"f128":"-","f140":"-","f141":"-","f136":"-","f152":2},{"f1":2,"f2":21.52,"f3":10.02,"f4":1.96,"f5":71732,"f6":151240608.0,"f7":9.97,"f8":5.92,"f9":192.0,"f10":2.21,"f11":0.0,"f12":"300380","f13":0,"f14":"安硕信息","f15":21.52,"f16":19.57,"f17":19.7,"f18":19.56,"f20":2957708800,"f21":2608249329,"f22":0.0,"f23":6.97,"f24":12.61,"f25":39.65,"f62":40619039.0,"f115":95.39,"f128":"-","f140":"-","f141":"-","f136":"-","f152":2},{"f1":2,"f2":27.01,"f3":10.02,"f4":2.46,"f5":84246,"f6":219853093.0,"f7":11.04,"f8":7.18,"f9":85.22,"f10":0.73,"f11":0.0,"f12":"002751","f13":0,"f14":"易尚展示","f15":27.01,"f16":24.3,"f17":24.3,"f18":24.55,"f20":4175762557,"f21":3169966689,"f22":0.0,"f23":4.04,"f24":24.87,"f25":25.86,"f62":64597906.0,"f115":49.84,"f128":"-","f140":"-","f141":"-","f136":"-","f152":2},{"f1":2,"f2":33.5,"f3":10.02,"f4":3.05,"f5":7118,"f6":23844931.0,"f7":0.0,"f8":1.58,"f9":108.74,"f10":2.91,"f11":0.0,"f12":"002961","f13":0,"f14":"瑞达期货","f15":33.5,"f16":33.5,"f17":33.5,"f18":30.45,"f20":14907500000,"f21":1507500000,"f22":0.0,"f23":9.01,"f24":401.5,"f25":401.5,"f62":18371667.0,"f115":129.93,"f128":"-","f140":"-","f141":"-","f136":"-","f152":2},{"f1":2,"f2":26.91,"f3":10.02,"f4":2.45,"f5":217836,"f6":574961248.0,"f7":9.08,"f8":10.22,"f9":54.18,"f10":1.3,"f11":0.0,"f12":"300458","f13":0,"f14":"全志科技","f15":26.91,"f16":24.69,"f17":24.69,"f18":24.46,"f20":8896735471,"f21":5735494039,"f22":0.0,"f23":4.19,"f24":25.81,"f25":36.6,"f62":58643249.0,"f115":71.3,"f128":"-","f140":"-","f141":"-","f136":"-","f152":2},{"f1":2,"f2":6.81,"f3":10.02,"f4":0.62,"f5":83794,"f6":56680352.0,"f7":10.18,"f8":1.74,"f9":211.1,"f10":1.37,"f11":0.0,"f12":"300290","f13":0,"f14":"荣科科技","f15":6.81,"f16":6.18,"f17":6.23,"f18":6.19,"f20":3771083202,"f21":3288862008,"f22":0.0,"f23":3.55,"f24":-2.01,"f25":73.28,"f62":22432152.0,"f115":164.19,"f128":"-","f140":"-","f141":"-","f136":"-","f152":2},{"f1":2,"f2":14.28,"f3":10.02,"f4":1.3,"f5":56518,"f6":77563179.0,"f7":10.63,"f8":12.71,"f9":213.08,"f10":3.82,"f11":0.0,"f12":"603683","f13":1,"f14":"晶华新材","f15":14.28,"f16":12.9,"f17":12.98,"f18":12.98,"f20":1808847600,"f21":635031600,"f22":0.0,"f23":2.29,"f24":3.33,"f25":3.63,"f62":14704570.0,"f115":184.63,"f128":"-","f140":"-","f141":"-","f136":"-","f152":2},{"f1":2,"f2":31.86,"f3":10.01,"f4":2.9,"f5":26669,"f6":83345178.0,"f7":11.6,"f8":9.18,"f9":29.86,"f10":1.55,"f11":0.0,"f12":"300752","f13":0,"f14":"隆利科技","f15":31.86,"f16":28.5,"f17":28.5,"f18":28.96,"f20":3703977331,"f21":925994333,"f22":0.0,"f23":4.7,"f24":8.07,"f25":-8.95,"f62":29842570.0,"f115":25.85,"f128":"-","f140":"-","f141":"-","f136":"-","f152":2},{"f1":2,"f2":16.26,"f3":10.01,"f4":1.48,"f5":24534,"f6":38740820.0,"f7":10.69,"f8":3.99,"f9":27.18,"f10":2.28,"f11":0.0,"f12":"002873","f13":0,"f14":"新天药业","f15":16.26,"f16":14.68,"f17":14.68,"f18":14.78,"f20":1903980960,"f21":1000634937,"f22":0.0,"f23":2.81,"f24":1.25,"f25":0.43,"f62":11495649.0,"f115":26.04,"f128":"-","f140":"-","f141":"-","f136":"-","f152":2},{"f1":2,"f2":10.11,"f3":10.01,"f4":0.92,"f5":132348,"f6":133803828.0,"f7":0.0,"f8":4.18,"f9":49.17,"f10":0.37,"f11":0.0,"f12":"300081","f13":0,"f14":"恒信东方","f15":10.11,"f16":10.11,"f17":10.11,"f18":9.19,"f20":5349786126,"f21":3198141138,"f22":0.0,"f23":2.06,"f24":1.61,"f25":13.6,"f62":17807754.0,"f115":82.34,"f128":"-","f140":"-","f141":"-","f136":"-","f152":2},{"f1":2,"f2":44.42,"f3":10.0,"f4":4.04,"f5":26505,"f6":117735476.0,"f7":0.0,"f8":5.26,"f9":61.73,"f10":9.92,"f11":0.0,"f12":"002962","f13":0,"f14":"五方光电","f15":44.42,"f16":44.42,"f17":44.42,"f18":40.38,"f20":8955072000,"f21":2238768000,"f22":0.0,"f23":5.79,"f24":157.21,"f25":157.21,"f62":60201138.0,"f115":60.66,"f128":"-","f140":"-","f141":"-","f136":"-","f152":2}]}});
业务代码:
import requests import io
def getHTML(url):
r = requests.get(url, stream=True)
#print(r.text)
r.encoding = 'utf8'
#print(r.json)
return r.content def WriteFile(path,msg):
#with open('test.txt', 'w') as f:
# f.write('Hello, world!')
file = open(path, 'a',encoding='gbk', errors='ignore')
f = file.write(str(msg.decode('utf-8')))
file.close()
# print(r.text)
# return r.content for num in list(range(1,193)):
url="http://78.push2.eastmoney.com/api/qt/clist/get?cb=jQuery112406092635132097686_1569674756779&pn="+str(num)+"&pz=20&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&fid=f3&fs=m:0+t:6,m:0+t:13,m:0+t:80,m:1+t:2,m:1+t:23&fields=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152&_=1569674756885"
print("第"+str(num)+"页")
msg= getHTML(url)
WriteFile("H:\gp.txt",msg)
Python 东方财富网-股市行情数据抓取的更多相关文章
- Python爬虫入门教程 24-100 微医挂号网医生数据抓取
1. 写在前面 今天要抓取的一个网站叫做微医网站,地址为 https://www.guahao.com ,我们将通过python3爬虫抓取这个网址,然后数据存储到CSV里面,为后面的一些分析类的教程做 ...
- 【Python入门只需20分钟】从安装到数据抓取、存储原来这么简单
基于大众对Python的大肆吹捧和赞赏,作为一名Java从业人员,我本着批判与好奇的心态买了本python方面的书<毫无障碍学Python>.仅仅看了书前面一小部分的我......决定做一 ...
- Python爬虫抓取东方财富网股票数据并实现MySQL数据库存储
Python爬虫可以说是好玩又好用了.现想利用Python爬取网页股票数据保存到本地csv数据文件中,同时想把股票数据保存到MySQL数据库中.需求有了,剩下的就是实现了. 在开始之前,保证已经安装好 ...
- python爬虫(一)_爬虫原理和数据抓取
本篇将开始介绍Python原理,更多内容请参考:Python学习指南 为什么要做爬虫 著名的革命家.思想家.政治家.战略家.社会改革的主要领导人物马云曾经在2015年提到由IT转到DT,何谓DT,DT ...
- Python爬虫工程师必学APP数据抓取实战✍✍✍
Python爬虫工程师必学APP数据抓取实战 整个课程都看完了,这个课程的分享可以往下看,下面有链接,之前做java开发也做了一些年头,也分享下自己看这个视频的感受,单论单个知识点课程本身没问题,大 ...
- Python爬虫工程师必学——App数据抓取实战
Python爬虫工程师必学 App数据抓取实战 整个课程都看完了,这个课程的分享可以往下看,下面有链接,之前做java开发也做了一些年头,也分享下自己看这个视频的感受,单论单个知识点课程本身没问题,大 ...
- 吴裕雄--天生自然python学习笔记:WEB数据抓取与分析
Web 数据抓取技术具有非常巨大的应用需求及价值, 用 Python 在网页上收集数据,不仅抓取数据的操作简单, 而且其数据分析功能也十分强大. 通过 Python 的时lib 组件中的 urlpar ...
- python爬虫数据抓取方法汇总
概要:利用python进行web数据抓取方法和实现. 1.python进行网页数据抓取有两种方式:一种是直接依据url链接来拼接使用get方法得到内容,一种是构建post请求改变对应参数来获得web返 ...
- 数据抓取分析(python + mongodb)
分享点干货!!! Python数据抓取分析 编程模块:requests,lxml,pymongo,time,BeautifulSoup 首先获取所有产品的分类网址: def step(): try: ...
随机推荐
- 伪分布式下Hadoop3.2版本打不开localhost:50070,可以打开localhost:8088
一.问题描述 伪分布式下Hadoop3.2版本打不开localhost:50070,可以打开localhost:8088 二.解决办法 Hadoop3.2版本namenode的默认端口配置已经更改为9 ...
- Angular5.0之 安装指定版本Angular CLI
我们可能会发现按照网上的方式下载安装后,使用Angular CLI生成的项目并不是我们想要的Angular的版本,因为在我们没有指定安装版本的前提下,默认会下载最新的版本安装,然而不同的Angular ...
- Python中异常和JSON读写数据
异常可以防止出现一些不友好的信息返回给用户,有助于提升程序的可用性,在java中通过try ... catch ... finally来处理异常,在Python中通过try ... except .. ...
- 5.Hiveguigun滚(ノ`Д)ノ竟然竞争谨慎谨慎谨慎哈喇子罢工八公
1.Hive简介 2.Hive部署与安装 3.Hive的使用 4.Hive JDBC编程
- Ceph 分布式存储架构解析与工作原理
目录 文章目录 目录 Ceph 简介 Ceph 的架构:分布式服务进程 Ceph Monitor(MON) Ceph Object Storage Device Daemon(OSD) Ceph Me ...
- datatable 用法
DataTable datainsert = dt.GetChanges(DataRowState.Added); DataTable datadelete = dt.GetChanges(DataR ...
- PHP+实现文件的上传和下载
工程截图 配置路径 修改系统配置文件路径 填写正确的项目路径 将loclahost:811/up6/改为实际项目路径. 文件和文件夹批量上传 当网络问题导致传输错误时,只需要重传出错分片,而不是整个文 ...
- OO ALV 后台运行时错误:Control Framework: Fatal error - GUI cannot be reached
这个错误的原因,是GUI容器依赖GUI的存在,因为它是在后台运行,没有GUI,因此控制错误. 可以通过做一些编码绕过这个. * ALV Grid DATA: R_GRID TYPE REF TO CL ...
- 了解XPath与XPath轴
XPath 是一门在 XML 文档中查找信息的语言.XPath 用于在 XML 文档中通过元素和属性进行导航. 节点(Node) 在 XPath 中,有七种类型的节点:元素.属性.文本.命名空间.处理 ...
- Django-ORM之ForeignKey的使用-多对一关系
ForeignKey使用俩表示两张表多对一关系的外键,外键字段要定义在多属性的表中. 定义外键时,to的表可以直接写类名,但是需要注意类的定义顺序:也可以写字符串式的类名,这样就可以忽略class类的 ...