如何使用新版本抓取foursquare?

how to use new version to scrape foursquare?

我正在尝试使用此代码从 foursquare 中抓取场地

def getNearbyVenues(names, latitudes, longitudes, radius=500):
    
    venues_list=[]
    for name, lat, lng in zip(names, latitudes, longitudes):
        print(name)
            
        # Create the API request URL
        url = 'https://api.foursquare.com/v3/places/nearby&client_id={}&client_secret={}&v={}&ll={},{}&radius={}&limit={}'.format(
            CLIENT_ID, 
            CLIENT_SECRET, 
            VERSION, 
            lat, 
            lng, 
            radius, 
            LIMIT)
            
        # Make the GET request
        results = requests.get(url).json()["response"]['groups'][0]['items']
        
        # Return only relevant information for each nearby venue
        venues_list.append([(
            name, 
            lat, 
            lng, 
            v['venue']['name'], 
            v['venue']['location']['lat'], 
            v['venue']['location']['lng'],  
            v['venue']['categories'][0]['name']) for v in results])

    nearby_venues = pd.DataFrame([item for venue_list in venues_list for item in venue_list])
    nearby_venues.columns = ['Neighborhood', 
                  'Neighborhood Latitude', 
                  'Neighborhood Longitude', 
                  'Venue', 
                  'Venue Latitude', 
                  'Venue Longitude', 
                  'Venue Category']
    
    return(nearby_venues)

但我遇到了这个错误

{
    "meta": {
        "code": 410,
        "errorType": "deprecated",
        "errorDetail": "Usage of the V2 Places API has been deprecated for new Projects. Please see our updated documentation for V3 for more details: https://docs.foursquare.com/reference",
        "requestId": "619928ff498a047e3a81f23a"
    },
    "response": {}
}

我应该在我的代码中编辑什么才能正常工作

这个我想不出来link https://developer.foursquare.com/reference/place-search

更新 @Corralien 的解决方案:

这是 results.json() 的结果 我正在尝试获取 Venue Venue Latitude Venue Longitude Venue Category 我必须写更多所以我的代码不是大部分代码

  'timezone': 'Europe/Helsinki'},
  {'fsq_id': '4adcdb23f964a520c76021e3',
   'categories': [{'id': 10031,
     'name': 'Science Museum',
     'icon': {'prefix': 'https://ss3.4sqi.net/img/categories_v2/arts_entertainment/museum_science_',
      'suffix': '.png'}}],
   'chains': [],
   'distance': 148,
   'geocodes': {'main': {'latitude': 60.171349882576,
     'longitude': 24.93154852286545}},
   'location': {'address': 'Pohjoinen Rautatiekatu 13',
    'country': 'FI',
    'cross_street': 'Arkadiankatu / Nervanderinkatu',
    'locality': 'Helsinki',
    'neighborhood': ['Etu-Töölö'],
    'postcode': '00100',

您必须在 get url 中使用 headersAPIKEY 而不是 CLIENT_ID / CLIENT_SECRET:

def getNearbyVenues(names, latitudes, longitudes, radius=500):
    headers = {
        'Accept': 'application/json',
        'Authorization': 'APIKEY'
    }

    URL = 'https://api.foursquare.com/v3/places/search?ll={},{}&radius={}&limit={}'

    venues_list = []
    for name, lat, lng in zip(names, latitudes, longitudes):
        print(name)

        url = URL.format(lat, lng, radius, LIMIT)
        data = requests.get(url, headers=headers).json()

        # do stuff here to process venues_list
        for record in data['results']:
            venues_list.append({
                'Neighborhood': name,
                'Neighborhood Latitude': lat,
                'Neighborhood Longitude': lng,
                'Venue': record['name'],
                'Venue Latitude': record['geocodes']['main']['latitude'],
                'Venue Longitude': record['geocodes']['main']['longitude'],
                'Venue Category': record['categories'][0]['name'],
            })

    # do stuff here to create your dataframe
    nearby_venues = pd.DataFrame(venues_list)

    return(nearby_venues)