In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about how to achieve visual data in Python. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
Crawler code
Request web page
Import requestsurl = 'https://xueqiu.com/service/v5/stock/screener/quote/list'response = requests.get (url=url, params=params, headers=headers, cookies=cookies) html_data = response.json () # for students who want the complete code, please follow the official Wechat account: squirrels love biscuits # send a message' stock'to get it.
Parsing data
Data_list = html_data ['data'] [' list'] for i in data_list: dit = {} dit ['stock symbol'] = I ['symbol'] dit [' stock name'] = I ['name'] dit [' current price'] = I ['current'] dit [' up and down'] = I ['chg'] dit [' up and down /%'] = I ['percent'] Dit ['year to date /%'] = I ['current_year_percent'] dit [' turnover'] = I ['volume'] dit [' turnover'] = I ['amount'] dit [' turnover /%'] = I ['turnover_rate'] dit [' P / E] = I ['pe_ttm'] dit [' dividend yield /%'] = I ['dividend_yield'] Dit ['market capitalization'] = I ['market_capital'] print (dit)
Save data
Import csvf = open ('stock data .csv', mode='a', encoding='utf-8-sig', newline='') csv_writer = csv.DictWriter (f, fieldnames= ['stock symbol', 'stock name', 'current price','up and down amount','up and down /%', 'year to date /%', 'volume', 'turnover', 'turnover /%', 'price / earnings ratio TTM',' dividend yield /%' 'Market value']) csv_writer.writeheader () csv_writer.writerow (dit) f.close ()
Data analysis code
C = (Bar () .add _ xaxis (list (df2 ['stock name'] .values)) .add _ yaxis ("stock volume situation", list (df2 ['volume] .values)) .set _ global_opts (title_opts=opts.TitleOpts (title= "volume chart-Volume chart"), datazoom_opts=opts.DataZoomOpts (),) .render ("data.html"))
The above is how to achieve visual data in the Python shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.