当前位置:网站首页>Get all stock data of big a
Get all stock data of big a
2022-07-05 12:12:00 【ziyi813】
Learn to practice reptile instances , Get stock data
Dongcai Weiwu , No crawler restrictions
https://www.eastmoney.com/robots.txt
obtain 4 Thousands of stock data are saved as csv
import requests
import re
import json
import time
def getApiRequest(url):
try:
headerParams = {
'user-agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36' }
r= requests.get(url, timeout=30, headers = headerParams)
r.raise_for_status()
return r
except:
return 'http request error !'
def rinseData(res):
try:
jsdata = re.findall(r'\(.*?\)', res.text)
dicts = json.loads(jsdata[0][1:len(jsdata[0])-1 ])
diff = dicts.get('data', []).get('diff', [])
return diff
except:
return []
def writeCsv(f, lslist):
try :
for item in lslist:
tmp = [item.get('f12'),item.get('f14'),item.get('f15'),item.get('f3'),item['f4'],item['f5'],item['f6'],item['f7'],item['f2'],item['f16'],item['f17'],item['f18'],item['f10'],item['f8'],item['f9'],item['f23'] ]
datastr = ''
for s in tmp:
datastr += str(s) + ','
f.write(datastr[:len(datastr)-1] + "\n")
except:
return 'write csv file Error'
def main():
total = 236
page = 20
start = time.perf_counter() # Starting time
f = open('gp.csv', 'w+', encoding='utf-8')
f.write(' Code , name , The latest price , applies , Up and down , volume ( hand ), turnover , The amplitude , The highest , The minimum , today , Yesterday , Volume ratio , Turnover rate , P / E ratio ( dynamic ), Market to net ratio \n')
for p in range(total):
a = "*" * p
b = "." * (total -p)
c = (p/total)*100
dur = time.perf_counter() - start
print("\r{:^3.0f}%[{}->{}]{:.2f}s".format(c,a,b,dur),end="")
url = 'http://81.push2.eastmoney.com/api/qt/clist/get?cb=jQuery1124017220261478010612_1636785244249&pn='+ str(p) +'&pz='+str(page)+'&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&fid=f3&fs=m:0+t:6,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&_=1636785244294'
res = getApiRequest(url)
lslist = rinseData(res)
writeCsv(f, lslist)
f.close()
print("\n"+" end of execution ".center(total//2,"-"))
main()

边栏推荐
- 1. Laravel creation project of PHP
- Halcon template matching actual code (I)
- 网络五连鞭
- Pytorch weight decay and dropout
- One article tells the latest and complete learning materials of flutter
- [cloud native | kubernetes] actual battle of ingress case (13)
- Application of a class of identities (vandermond convolution and hypergeometric functions)
- Simply solve the problem that the node in the redis cluster cannot read data (error) moved
- Programmers are involved and maintain industry competitiveness
- 15 methods in "understand series after reading" teach you to play with strings
猜你喜欢

【TFLite, ONNX, CoreML, TensorRT Export】

Uniapp + unicloud + Unipay realize wechat applet payment function

《增长黑客》阅读笔记

pytorch-多层感知机MLP

Use and install RkNN toolkit Lite2 on itop-3568 development board NPU

16 channel water lamp experiment based on Proteus (assembly language)

Linux Installation and deployment lamp (apache+mysql+php)

Mongodb replica set

Intern position selection and simplified career development planning in Internet companies
![[configuration method of win11 multi-user simultaneous login remote desktop]](/img/8f/eab81f089b236c4527a9866b2cfc25.png)
[configuration method of win11 multi-user simultaneous login remote desktop]
随机推荐
Liunx prohibit Ping explain the different usage of traceroute
语义分割实验:Unet网络/MSRC2数据集
JS for loop number exception
Embedded software architecture design - message interaction
Hiengine: comparable to the local cloud native memory database engine
Matlab label2idx function (convert the label matrix into a cell array with linear index)
【load dataset】
【 YOLOv3中Loss部分计算】
【SingleShotMultiBoxDetector(SSD,单步多框目标检测)】
【Win11 多用户同时登录远程桌面配置方法】
Simple production of wechat applet cloud development authorization login
手机 CPU 架构类型了解
codeforces每日5题(均1700)-第五天
一类恒等式的应用(范德蒙德卷积与超几何函数)
yolov5目标检测神经网络——损失函数计算原理
[untitled]
Error modulenotfounderror: no module named 'cv2 aruco‘
【使用TensorRT通过ONNX部署Pytorch项目】
【TFLite, ONNX, CoreML, TensorRT Export】
一款新型的智能家居WiFi选择方案——SimpleWiFi在无线智能家居中的应用