[問題] 關於 parsing 的量太大..
請教~
在下現有一個檔案 內含2萬多筆的地址資料
目前要拿著這兩萬多筆的資料逐筆向 google maps geocode 查詢經緯度
但是可能是量大的關係 跑到1xx筆就噴出:
urllib2.HTTPError: HTTP Error 400: Bad Request
不知道有沒有好方法能避開這個問題~感謝
原 code:
# -*- coding: utf-8 -*-
import urllib2, json
fobj = file('stores.txt', 'r')
for line in fobj:
items = line.strip().split(';')
values = ''
jsondata = json.load(urllib2.urlopen('http://maps.googleapis.com/maps/api/geocode/json?address=' + items[0] + '&sensor=false'))
if(jsondata["status"] == 'OK'):
values = str(jsondata["results"][0]["geometry"]["location"]["lat"]) + ';' + str(jsondata["results"][0]["geometry"]["location"]["lng"])
if(jsondata["status"] != 'OK'):
values = 'error'
print values
fobj.close()
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.33.253.178
→
06/26 00:46, , 1F
06/26 00:46, 1F
→
06/26 07:34, , 2F
06/26 07:34, 2F
→
06/26 07:35, , 3F
06/26 07:35, 3F
→
06/26 09:33, , 4F
06/26 09:33, 4F
推
06/26 10:50, , 5F
06/26 10:50, 5F
→
06/26 10:51, , 6F
06/26 10:51, 6F
→
06/26 15:51, , 7F
06/26 15:51, 7F
討論串 (同標題文章)
完整討論串 (本文為第 1 之 2 篇):