都市データの高い道徳的なマップを取得scrapy

次のように#spiderページサービスロジックがある:
インポートScrapy

インポートJSONの

クラスAmapSpider(scrapy.Spider):
NAME = 'AMAP'
allowed_domains = [ 'amap.com']
start_urls = [「https://www.amap.com/service/cityList ?= 201 982 221版「]
sort_city_OK = {}
sort_province_OK = {}
アイテム= {}
解析(自己応答)DEF:
結果= json.loads(response.text)
DT =結果[ "データ"]
hot_city DT = [「CityData "]#人気のある都市、無駄
sort_cityのDT = [" cityByLetter "] #1 行都市別
sort_province = DT [" provinceByLetter「] #1 行州によって

sort_city.itemsでK、V(用):
self.sort_city_OK [K] = [D [ "名前"]のための V IN D]

kに対して、sort_province.itemsにおけるV():#1、K = A、B、C ...
temp_province_dict = {}
V IN州用:
K2、province.itemsにおけるV2()のために:
temp_province_dict [K2] = [N [ V2でnの"名前"]
self.sort_province_OK [K] = temp_province_dict
self.item = { "sort_city":self.sort_city_OK、 "sort_province":self.sort_province_OK}
プリント(self.item)
収量self.item

おすすめ

転載: www.cnblogs.com/yiyea/p/11496533.html