Eleven one holiday is approaching, I don’t know you have a good idea where to play.

Although every holiday, the major domestic tourist attractions are overcrowded, but it is necessary to go out to put out the wind, you can come across the little brother little sister!

Since it is to go out to relax, then the weather is particularly important, rainy and cloudy day, cold wind, may not be good to encounter oh. Let’s take a look at where the weather is good for going out during the National Day holiday.

To get the data

To obtain the data, we grab it directly from the Chinese weather website. Some API on the Internet, some information is not very complete, can only obtain the data of the last 3 days, and some need to pay, it is better to grab it by ourselves.

www.weather.com.cn/weather15d/…

The site also did not do any restrictions, simple raking web code on the line, not difficult.

At the same time, I also used four files prepared by extraction

  • List of provincial capitals, Provincial_Capital
  • National City ID information table, China-city-list.csv
  • A list of famous attractions
  • National scenic spot ID information table, China-scenic -list.txt

For the convenience of reading, only the core scraping part is given here, other save data part can view the source code

def get_data(name, city, code) :
    print("Downloading data for city %s" % city)
    url = 'http://www.weather.com.cn/weather15d/%s.shtml' % code[2:]
    res = requests.get(url).content.decode()
    content = BeautifulSoup(res, "html.parser")
    weather_list = content.find('ul', attrs={'class': 't clearfix'}).find_all('li')
    items = map(parse_item, weather_list)
    save_to_csv(name, city, items)
    time.sleep(1)


def parse_item(item) :
    time = item.find('span', attrs={'class': 'time'}).text
    wea = item.find('span', attrs={'class': 'wea'}).text
    tem = item.find('span', attrs={'class': 'tem'}).text
    wind = item.find('span', attrs={'class': 'wind'}).text
    wind_level = item.find('span', attrs={'class': 'wind1'}).text
    result = {
        "time": time,
        "wea": wea,
        "tem": tem,
        "wind": wind,
        "wind_level": wind_level
    }
    return result
Copy the code

Finally, I got two files containing weather information, shiyi_weather_data. CSV and shiyi_attraction_data. CSV. The following are the two files to plan the schedule of the next Eleven.

Analysis of provincial capital Cities

When you travel, the provincial capital must be a priority, after all, big cities, you know.

Temperature and Precipitation

As for the probability of precipitation, IF the forecast is rain, the probability of precipitation is set as 80, and if the forecast is sunny, the probability of precipitation is 20.

weather_dict = {
    "snow": 100."rain": 80."cloud": 50."overcast": 60."sun": 20
}
Copy the code

On October 1, precipitation and temperature in capital cities of each province

As you can see, most of the cities will have the probability of precipitation, but it is not very high. Conservatively, it will be sunny. And the temperature, the basic are between 25-28 degrees, the real cool days a good autumn ah!

And Urumqi, Lhasa, Xining temperature is not very good, basically has reached 10 degrees, small cotton-padded jacket is not to go up.

To make this more intuitive, let’s look at the situation of falling water and temperature through a biaxial diagram

This picture is even more obvious, Nanning, Fuzhou, Zhengzhou and Changsha are the cities with the best weather, with crisp autumn air. So, would you choose one of these cities?

Urumqi, on the other hand, managed to become the coldest provincial capital in China, even beating Harbin.

Here are a few more tourist cities to see the weather during the National Day holiday

Beijing

Due to the high latitude in Beijing, the temperature is also relatively low during the National Day, and the probability of precipitation is quite large, it seems that an autumn rain and a cold ah, the great emperor will enter the season of depression.

Shanghai

The average temperature of Shanghai is still very good, I feel that two days before the National Day, as long as I can hold the impact of the crowd, Shanghai will be a good choice.

hangzhou

The temperature in Hangzhou has been falling all the way during the National Day holiday. According to this situation, the day of snow falling off the bridge is not far away. And during the National Day probability is cloudy, in the misty west Lake side of the walk, have a feeling?

chengdu

Chengdu is as steady as ever, the rain does not stop. But this also does not affect us to see giant pandas, anyway I do not care, I want to go to Chengdu!

Weather of Famous Scenic Spots

Different people must have different definitions of famous scenic spots. I only selected some scenic spots with the highest appeal on the Internet to do analysis, but could not completely cover them. After all, our great motherland is vast and there are too many interesting places!

precipitation

Feel li River and Huangshan can go ah, big sunny day.

Temperature and Precipitation

Then combine the temperature to see, feeling or huangshan and Lijiang River is the most suitable to go, Wulingyuan scenic area is also a good choice.

Among the scenic spots I chose, changbai Mountain has the lowest temperature. After all, it is in the northeast and has a high altitude. But the nature reserve to see the purest nature, should also have a different feeling.

Geographical distribution of temperature and precipitation

precipitation

It can be clearly seen that the possibility of precipitation in Beijing and Tianjin is the largest. If you walk on the streets of Beijing at this time, you do not know how you will feel when the cold rain hits your face?

Southeast coastal precipitation will not be less, so the choice of west Lake should be the best choice.

The temperature

On the whole, the temperature will be higher in places with lower latitudes. The Pearl River Delta region should still have spring blossoms, while northeast China and Xinjiang may have to prepare for the cold.

Well, that’s all for today’s analysis. So, where will you choose during the National Day holiday?

Finally, present the complete code

Github.com/zhouwei713/…