Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use Python to climb the comment data of Meituan's tourist attractions

Shulou Source: shulou.com Published: 2022-06-02 06:05:26 10月03日 Update

This article mainly explains "how to use Python to climb Meituan tourist attractions review data", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "how to use Python to climb Meituan tourist attractions review data"!

Preface

The text and pictures of this article come from the network, only for learning, communication and use, do not have any commercial use, if you have any questions, please contact us in time to deal with.

This year's National Day is coming in half a month. I believe many friends are still very much looking forward to this short holiday. National Day is a short holiday of the year, and many friends choose to travel to spend it. There are many tourist cities and tourist attractions in China.

Project goal

Climb Meituan's comments on tourist attractions

Victim's website

[https://chs.meituan.com/](https://chs.meituan.com/) Code installation Library pip install requestspip install time Import tool import requestsimport time parsing website Crawl data for page in range (10,101,10): time.sleep (1) url = 'https://www.meituan.com/ptapi/poi/getcomment?id=1161635&offset=0&pageSize={}&sortType=1'.format(page) headers = {' Host': 'www.meituan.com',' Pragma':'no-cache', 'Referer':' https: / / www.meituan.com / zhoubianyou / 1161635 /' 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0 WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36'} response = requests.get (url=url, headers=headers) html_data = response.json () info_data = html_data ['comments'] for i in info_data: info = I [' comment'] Save data for i in info_data: info = I ['comment'] with open (' Meituan comment .csv' Mode='a', encoding='utf-8-sig', newline='') as f: f.write (info) print (info) run code The effect is as follows

Thank you for your reading, the above is the content of "how to use Python to climb Meituan tourist attractions review data". After the study of this article, I believe you have a deeper understanding of how to use Python to climb Meituan tourist attractions review data, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Tourism data tourist attractions scenic spots reviews learning codes content National Day long holidays questions numerous prefaces victims businesses pictures cities boys buddies just Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Microsoft Docker Shulou Technology vpn