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 does Python crawl Anjuke's rental data and set up data other than his own conditions?

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article is about how Python crawls Anjuke rental data and sets data excluding its own conditions. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it.

Preface

The editor may be ready to go to Shenzhen and need to rent a house. I checked it on the Internet and found that there were a lot of rental software, Anjuke, shells, etc., and asked people around me. Anjuke heard more times, so he chose Anjuke to check some rental information.

In the process of browsing, although Anjuke has filter tags, which are filtered by price, region, room type, and type, he still feels that it is not ideal information, and there is so much that he can't see it.

So the editor decided to use python to crawl the above data, and set their own filter conditions, filter out the housing they need from many housing sources, not only improve efficiency, but also find a more ideal one. .

Because the region does not know much about the scope of each district, it does not know the distance of each region, and it is too single to choose only one area, so it is impossible to understand the whole, so the region chooses all the labels by default.

There are 60 pieces of data on a page, there are 50 pages, and you can get 3000 pieces of data, which is enough to read too much.

The logic of the crawler is not difficult, from the first page to the last page, first crawl each page of the housing link, from climbing the details of the link.

The main crawl title, housing information, housing facilities, housing overview:

The core code is as follows:

The second problem is that you will encounter a CAPTCHA, which may be a font click or a slider, which is very troublesome, so this editor determines whether a CAPTCHA appears in the program.

The CAPTCHA program will output the prompt. After clicking the CAPTCHA manually, press enter to continue crawling. In the crawling process, the editor has encountered CAPTCHA only once.

Other logic is relatively simple, interested in the reference source code.

Data filtering

If you get the data, you can set your own filter conditions, because the editor needs to know where each housing source is, and first construct the area of each housing source:

If there is a [number of line] in the label that represents which line of the subway, it should also be mentioned in the overview, otherwise it is suspected to be deceptive, so if you filter these two lines, you will filter more than 2000 lines at a time.

After filtering, there are more than 200 left, which is still a little too much, and now it contains all the areas:

The editor extracted a few pieces of data and clicked on the link, and most of them were acceptable. In order to make a point, I should say that I am very sad now.

The above is how Python crawls Anjuke rental data and sets up data excluding its own conditions. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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

Internet Technology

Wechat

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

12
Report