Let’s talk about how to download A-share historical market to local excel. It’s not difficult to download A-share historical market trend data. Many clients of securities companies have provided it before, but now it seems that there are no restrictions or restrictions.
Only need two steps, 0 ￥, don’t download software, download online anytime and anywhere
Download in two steps:
- Fill in stock code and email
- We will receive the historical data of the stock market in Excel in 5 minutes
It’s really helpless to download it on the princess. I hope you can understand [otherwise it’s easy to be downloaded maliciously]. It’s very convenient to download. You can do two steps in the princess, i.e. 1 and 2, and you can receive the data in five minutes.
Online download is easy to be infinitely malicious download, which greatly affects the download of normal users. So later, in order to block these malicious downloads, we set up the way of submitting and sending e-mail through Princess number.
It’s because online download is easy to be attacked and downloaded maliciously, so we finally chose to put it on princess. In this case, wechat should be the first one to attack. No one should have such great ability. So this method is m-fee (0 ￥), and it can last for a long time. I hope everyone can understand it
Now do online download, basically are routine money, do not believe you have to find a circle back
If you know the code, it’s simpler. I’ll send you the code directly
import re import pandas import requests Url ='the URL of the target website '# there is no link to the specific website. The general practice is the same. Response = requests. Get (URL). Text # get the source code of the web page ###The following is the code to parse the opening data, most of which can be referred to as simple regular expressions### times = re.findall('class="first left bold noWrap">(.*?)</ Td > '). Group (1) # get all historical transaction times open_ price = re.findall('class="first left bold noWrap">.*?</ td>\s+<td data-real-value="(.*?)"'). Group (1) # get all historical opening price data close_ price = re.findall('class="first left bold noWrap">.*?</ td>\s+<td.*?</ td>\s+<td data-real-value="(.*?)">'). Group (1) # get all historical closing price data high_ price = re.findall('class="first left bold noWrap">.*?</ td>\s+<td.*?</ td>\s+<td.*?</ td>\s+<td data-real-value="(.*?)">'). Group (1) # get all historical closing price data ###The following is the data part of data download cost, take download as local excel as an example### df = pandas.DataFrame(a, columns=['open_ price', 'close_ Price ','vol'], which converts data into dataframe format Wt = excelwriter (path) # path is the path to save the file, which should be accurate to the file name. After downloading the cost data, you need to go to this path. For example: C: \ \ users \ \ administrator \ \ desktop \ \ all historical opening data of stocks download cost data. XLS just follow this path to find the saved excel df.to_ excel(wt, sheet_ Name ='How to download the historical closing price of a stock ', index = false)