2015-08-27 80 views
-1

我嘗試使用python獲取地圖服務的圖像。 谷歌靜態地圖和mapquestapi.com不起作用。當我嘗試從erverything正常工作的其他服務器檢索靜態圖像,但在地圖服務的,我得到這個錯誤:無法從Python中的地圖服務中獲取圖像

ERROR handlers: message: plugins.xxx._scan_for_triggers : coroutine 
Traceback (most recent call last): 
File "/xxx/handlers.py", line xxx, in run_pluggable_omnibus 
yield from function(*_passed) 
File "/xxx/plugins/xxx.py", line 54, in _scan_for_triggers 
img_id = yield from xxx._client.upload_image(img_data, filename=filename) 
File "/usr/local/lib/python3.4/site-packages/xxx/client.py", line 472, in upload_image 
upload_url = (json.loads(res1.body.decode())['sessionStatus'] 
KeyError: 'sessionStatus' 

下面的代碼:

r = yield from aiohttp.request('get', img_link) 
raw = yield from r.read() 
img_data = io.BytesIO(raw) 
filename = "xxx" 
img_id = yield from xxx._client.upload_image(img_data, filename=filename) 

回答

0

我固定它。 img_link是一個字符串,包含參數。 我不得不使用urllib.parse.urlencode構建url