Article From:https://www.cnblogs.com/Python1234/p/9063560.html

Is there so many unlicensed stores on top of it! It's a big Python.

Let’s take a look at the screenshots. There are so many stores that have no business licenses.

Is there so many unlicensed stores on top of it! It's a big Python.

Is there so many unlicensed stores on top of it! It's a big Python.

Two. Operating environment

  • python3

  • pymongo

  • requests

Three. Analysis

First, visit the hungry homepage, enter the area you want to search, and then return to the shops nearby.

Is there so many unlicensed stores on top of it! It's a big Python.

Is there so many unlicensed stores on top of it! It's a big Python.

The page browser address is as follows:

https://www.ele.me/place/wtw39y8614v4?latitude=31.237236&longitude=121.36636

Open the browser developer tool, analyze the data that you need to grab, then use requests to grab the page address, and use BeautifulSoup to parse the data, and return to the empty value data.

Check the page information again and scroll down the page. It is found that there are JSON format data in the XHR asynchronous loading type. As shown in the following figure:

Author: Mai Kou Hu

Link: https://www.jianshu.com/p/19c38bfa7388

Source: Jane book

The copyright is owned by the author. For commercial retransmission, please contact the author for authorization.

Is there so many unlicensed stores on top of it! It's a big Python.

Is there so many unlicensed stores on top of it! It's a big Python.

The parameters are:

1、longitude,latitudeThe High German coordinate system corresponds to the longitude and latitude of the search area.

2、limit=24 The maximum limit is 24 stores, and more backups are returned to 30 stores.

3、offset=24 The number of shops returned each time increased by 24 orders of magnitude, for example, the page continued to turn offset=48,72…

By increasing the offset of offset by cycle, more store data can be obtained.

This page we need to collect name, phone, address, that is, business name, telephone, business address three data can be. A page can collect 24 merchant data. The JSON data are shown below.

Is there so many unlicensed stores on top of it! It's a big Python.

The code is as follows:

import requestsimport jsonurl='https://www.ele.me/restapi/shopping/restaurants?extras[]=activities&geohash=wtw39y8614v4&latitude=31.237236&limit=24&longitude=121.36636&offset=24&terminal=web'r=requests.get(url).textd=json.loads(r)for v in d: print (v['name'],v['phone'],v['address'])

The return results are as follows:

Is there so many unlicensed stores on top of it! It's a big Python.

Is there so many unlicensed stores on top of it! It's a big Python.

Is there so many unlicensed stores on top of it! It's a big Python.

Is there so many unlicensed stores on top of it! It's a big Python.

Four, code screenshot

Is there so many unlicensed stores on top of it! It's a big Python.

Five. The result shows

Sort by address in mongodb, and sort ({address:1}) sort according to address ascending order.

Is there so many unlicensed stores on top of it! It's a big Python.

Is there so many unlicensed stores on top of it! It's a big Python.

Is there so many unlicensed stores on top of it! It's a big Python.

Is there so many unlicensed stores on top of it! It's a big Python.

Have you learned?

Welcome to my blog: ttps://home.cnblogs.com/u/Python1234

Welcome to join thousands of people to exchange questions: 125240963

Leave a Reply

Your email address will not be published. Required fields are marked *