Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to capture and analyze Weather data by Scrapy in Python

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Today, I will talk to you about how Scrapy grabs and analyzes weather data in Python. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.

Use Python to "simply" grab and analyze weather data. Fill in the gaps in previous data visualization.

Development tools

Python version: 3.6.4

Related modules:

PIL module

Requests module

Pyecharts module

And some modules that come with Python.

Environment building

Simple analysis of Wechat friends with Python.

Main ideas

Use the National Weather Administration and Baidu Weather query API interface to obtain the current weather data, including temperature, humidity, air pressure and so on.

After obtaining the relevant data, the pyecharts module and PIL module are used to visually analyze the data.

For more information on the implementation process, please see personal introduction or private message access to the source code.

Result display

Use:

Just run the analysis.py file in the cmd window.

What diagram do you want to draw and remove the corresponding function call comments?

Picture

Results:

(it is better to open the html file in the relevant files. There are surprises everywhere.)

(1) Air quality in some cities in China

Picture

(2) Weather forecast diagram

Picture

(3) temperature bar chart of some cities

Picture

(4) temperature line chart of some cities

Picture

(5) relative air pressure pie chart of some cities

Picture

(6) temperature distribution map of some cities

Picture

(7) Urban humidity in Beijing

Picture

(8) Weather Information Radar Map of Nanjing

Picture

Some of them draw for the sake of drawing, so it looks very logical.

Supplement: data Visualization of China Seismological Network

Let's visualize the data we crawled.

First of all, draw the thermal map of the frequency of earthquakes according to the longitude and latitude. In order to facilitate statistics, we retain a decimal place for the longitude and latitude, and then carry on the frequency statistics, so the thermal map will have errors.

* * Note: the data is derived from http://news.ceic.ac.cn/index.html and is for reference only. **

The overall effect is as follows:

Picture

Compare it with the distribution of the world earthquake zones found by Google:

Picture

It's all right, that's why the Chinese piece is so outstanding. However, it is also right to think about it. Domestic earthquake data are definitely more detailed, and very low-level earthquakes are also counted, while foreign earthquake statistics are a little rougher, so they have missed a lot. This is what it looks like. So we might as well take a closer look at the domestic ones. So zoom in and take a look at China, and the effect is as follows:

Picture

Well, the land area of China is too large, it is not easy to display, interested partners download the relevant files to see. T_T

And then count the frequency of earthquakes every year? The effect is as follows:

Picture

And earthquake magnitude statistics? The effect is as follows:

Picture

Finally, draw a word for all the places where there has been an earthquake:

After reading the above, do you have any further understanding of how Scrapy grabs and analyzes weather data in Python? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report