Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to crawl and simply analyze the data of A-share companies with Python

Shulou Source: shulou.com Published: 2022-05-31 10:44:03 10月28日 Update

This article mainly explains "how to use Python to crawl and simply analyze A-share company data", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to crawl and simply analyze the data of A-share companies with Python.

Development tool Python version: 3.6.4 related modules:

Requests module

Bs4 module

Lxml module

Pyecharts module

Wordcloud module

Jieba module

And some modules that come with Python.

Environment building

Install Python and add it to the environment variable, and pip installs the relevant modules you need.

Data crawling

Target website:

Http://www.askci.com/reports/

The data to be crawled is shown below:

Do not bother to think, directly with the help of BeautifulSoup to extract these data, simple and rough, the source code is as follows:

For more information on the complete source code, please see the Spider.py file in the personal home page or private message to get the relevant documents.

The screenshot of the running effect is as follows:

All done~

Data analysis

In the part of data crawling, we have obtained a total of 3573 pieces of A-share company data. Let's simply visually analyze a wave.

First, let's take a look at the regional distribution of A-share companies:

Among them, the provinces with more than 300 A-share companies are:

Guangdong

Beijing

Zhejiang

Jiangsu Province

Next, let's take a look at the income of A-share companies:

Among them, the main business income TOP10 is:

Let's take a look at the number of employees of A-share companies:

Let's take a look at the listing time distribution of A-share companies:

Among them, the lowest number of companies listed in 2013 (2); the largest number of listed companies in 2017 (438).

OK, why don't we take a look at the industry type of A-share companies as a percentage of TOP10:

At this point, I believe you have a deeper understanding of "how to use Python to crawl and simply analyze A-share company data". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Company data module analysis quantity content revenue file source code environment website learning practical deeper rough next business interest region variable Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Tech Info MariaDB Apple Redmi