首页 > 解决方案 > Python 请求 POST - 408 超时

问题描述

我正在尝试使用 HERE.com 上的 Batch API 在 Python 中对地址进行地理编码(https://developer.here.com/api-explorer/rest/batch_geocoding/batch-geocode-addresses

url = 'https://batch.geocoder.api.here.com/6.2/jobs?app_id={APP_ID}&app_code={APP_CODE}&indelim=%7C&outdelim=%7C&action=run&outcols=displayLatitude%2CdisplayLongitude%2ClocationLabel&outputcombined=true'.format(APP_ID=appId, APP_CODE=appCode)

headers = {'content-type': 'text/plain', 'Accept-Charset': 'UTF-8'}

payload = open('payload_sm.txt')

r = requests.post(url, data=payload, headers=headers)

这给了我:

408 请求超时

请求超时

服务器超时等待来自客户端的 HTTP 请求。


我不确定 txt 文件的格式是否正确。从视觉上看,它看起来像他们的样本输入。如果那是问题,我想我会收到“ 400 Bad Request ”。

标签: pythonpython-3.xrestpython-requestsgeocoding

解决方案


推荐阅读