Current location - Training Enrollment Network - Books and materials - How to use Gaud API (Search Points of Interest)
How to use Gaud API (Search Points of Interest)
1. First, we need to load the request module;

Import request

2. Import the panda library;

Import pandas as pd

3. Enter the key you applied for in Gaode, the keyword you searched, and the code corresponding to the city;

In this example, the keyword is "Library" and the region is Guangzhou (corresponding code is 440 1 10).

4. Build the final result list pois

pois = []

5. Construct pg_no, and give different optional parameter page values each time;

pg_no = 1

6. Iterate until you jump out of the break.

Specific steps:

parameters . update({ ' page ':pg _ no })

Pois.extend (data ['pois'])

no_pois_this_search = len(pois)

no_pois = int(data['count'])

7. Use pandas module to process data;

Df _ input = pd. data frames

8. Select the fields to output;

9. Use pandas module to output data, the file formats are tsv and json respectively, and the file name is "output" (which can be named by itself);

df.to_csv("output.tsv ",encoding="utf8 ",sep='\t ')

df.to_csv("output.json ",encoding="utf8 ",sep='\t ')

10. After running, you can get the corresponding tsv file and json file, which contain the relevant information you want, as shown in the figure below.