如何访问 Here Maps API PlacesResponse 中的下一个结果列表?

How to access the next list of results in Here Maps API PlacesResponse?

我一直在使用 Herepy 软件包在 python 上使用 Here Maps API,我终于得到了一些结果。我很难访问我得到的 PlacesResponse 中的下一页结果。

代码:

response = geocoderApi.onebox_search([12.8797, 121.7740], 'mall')

结果:

{'results': {'next': 'https://places.ls.hereapi.com/places/v1/discover/search;context=Zmxvdy1pZD1jNDhkZGI5ZC1hY2E0LTU3MDctOTEzOS1jOTk3MmU1NWFkNDdfMTU3OTIzNDM1MjU3N18xNDM1XzQ2MzAmb2Zmc2V0PTIwJnNpemU9MjA?at=12.8797%2C121.774&q=mall','items': [{'position': [12.57726, 122.26888],
'distance': 63341,
'title': 'Romblon Shopping Center',
'averageRating': 0.0,
'category': {'id': 'mall',
 'title': 'Shopping Centre',
 'href': 'https://places.ls.hereapi.com/places/v1/categories/places/mall',
 'type': 'urn:nlp-types:category',
 'system': 'places'},
'icon': 'https://download.vcdn.data.here.com/p/d/places2/icons/categories/09.icon',
'vicinity': 'Bagacay, Romblon<br/>Philippines',
'having': [],
'type': 'urn:nlp-types:place',
'href': 'https://places.ls.hereapi.com/places/v1/places/608jx7ps-e037893cbff505fbef78dc1294497c1d;context=Zmxvdy1pZD1jNDhkZGI5ZC1hY2E0LTU3MDctOTEzOS1jOTk3MmU1NWFkNDdfMTU3OTIzNDM1MjU3N18xNDM1XzQ2MzAmcmFuaz0w',
'id': '608jx7ps-e037893cbff505fbef78dc1294497c1d'}
...

我尝试通过在请求中添加我的 API 键来访问 next link,但我似乎无法获得下一个结果列表.

next_results = requests.get('https://places.ls.hereapi.com/places/v1/discover/search?apiKey={API_KEY_HERE};context=Zmxvdy1pZD1jNDhkZGI5ZC1hY2E0LTU3MDctOTEzOS1jOTk3MmU1NWFkNDdfMTU3OTIzNDM1MjU3N18xNDM1XzQ2MzAmb2Zmc2V0PTIwJnNpemU9MjA?at=12.8797%2C121.774&q=mall')

https://places.ls.hereapi.com/places/v1/discover/search?apiKey={API_KEY_HERE};context=Zmxvdy1pZD1jNDhkZGI5ZC1hY2E0LTU3MDctOTEzOS1jOTk3MmU1NWFkNDdfMTU3OTIzNDM1MjU3N18xNDM1XzQ2MzAmb2Zmc2V0PTIwJnNpemU9MjA?at=12.8797,121.774&q=mall

您的 下一个 url 格式不正确。 apiKey 应该与其他查询字符串参数 atq:

一起

https://places.ls.hereapi.com/places/v1/discover/search;context=Zmxvdy1pZD1jNDhkZGI5ZC1hY2E0LTU3MDctOTEzOS1jOTk3MmU1NWFkNDdfMTU3OTIzNDM1MjU3N18xNDM1XzQ2MzAmb2Zmc2V0PTIwJnNpemU9MjA?apiKey=API_KEY_HERE&at=12.8797,121.774&q=mall

使用正确格式的 next url,我得到以下针对您使用的坐标和 mall 搜索词的响应:

{
    "previous": "https://places.ls.hereapi.com/places/v1/discover/search;context=Zmxvdy1pZD01NWRiOTk5NC0zM2ZmLTUwMjctOWRmOC01MmE5YzMyZmJhM2RfMTU3OTI1OTczODg3NF84MjYxXzE3NDQmb2Zmc2V0PTAmc2l6ZT0yMA?at=12.8797%2C121.774&q=mall",
    "next": "https://places.ls.hereapi.com/places/v1/discover/search;context=Zmxvdy1pZD01NWRiOTk5NC0zM2ZmLTUwMjctOWRmOC01MmE5YzMyZmJhM2RfMTU3OTI1OTczODg3NF84MjYxXzE3NDQmb2Zmc2V0PTQwJnNpemU9MjA?at=12.8797%2C121.774&q=mall",
    "offset": 20,
    "items": [
        {
            "position": [
                11.962863,
                121.925928
            ],
            "distance": 103274,
            "title": "Mit",
            "averageRating": 0.0,
            "category": {
                "id": "mall",
                "title": "Shopping Centre",
                "href": "https://places.ls.hereapi.com/places/v1/categories/places/mall",
                "type": "urn:nlp-types:category",
                "system": "places"
            },
            "icon": "https://download.vcdn.data.here.com/p/d/places2/icons/categories/09.icon",
            "vicinity": "Balabag, Malay, 5608<br/>Philippines",
            "having": [],
            "type": "urn:nlp-types:place",
            "href": "https://places.ls.hereapi.com/places/v1/places/608wdnsn-d3edd5c804da4698bc913e04da8ca891;context=Zmxvdy1pZD01NWRiOTk5NC0zM2ZmLTUwMjctOWRmOC01MmE5YzMyZmJhM2RfMTU3OTI1OTczODg3NF84MjYxXzE3NDQmcmFuaz0yMA",
            "id": "608wdnsn-d3edd5c804da4698bc913e04da8ca891"
        },
        ...
    ]
}