Python crawler + visualizing stock prices

https://www.eastmoney.com/Take
Eastern Fortune as an example
Insert picture description here
Insert picture description here
Insert picture description here
https://curl.trillworks.com/#Put
Insert picture description here
the copied result into the Python crawler generation page and put the result obtained into pycharm

Insert picture description here
Insert picture description here
Run to get a status code of 200

#print(response.text)
resp_dict = json.loads(response.text)
#得到字典里嵌套的字典
datas = resp_dict.get('data').get('diff')
#print(datas)
# 满足条件的公司名字
companies = []

# 满足要求的公司股价
prices = []

for data in datas:
    #print(data)
     # 1.公司名
    company = data.get('f14')
     # 2.机构买入市场份额
    share = data.get('f184')
     # 3.股价
    price = data.get('f2')

     #自动化筛选 设定条件
    if share >=10 and price >= 15:
        # print(company)
        companies.append(company)
        prices.append(price)
#
print(companies)
print(prices)

from pyecharts.charts import Bar
import pyecharts.options as opts

bar = Bar()  # 面向对象
bar.add_xaxis(companies)
bar.add_yaxis("股价图",prices)

bar.set_global_opts(
    xaxis_opts=opts.AxisOpts(
        #定义X轴的数据
        axislabel_opts=opts.LabelOpts(rotate=-45),

    ),
        #定义Y轴的数据
        yaxis_opts=opts.AxisOpts(name='价格:(元/股)')
)
#生成一个html
bar.render('股价图.html')

Insert picture description here

Guess you like

Origin blog.csdn.net/APPLEaaq/article/details/108860006