码迷,mamicode.com
首页 > 编程语言 > 详细

python3+获取地图高新企业坐标

时间:2021-04-27 14:44:15      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:shu   mac   cti   bmc   zoom   tin   company   gecko   -o   

# -*- coding:utf-8 -*-
import json
import xlwt
from datetime import datetime
import time
import os
import urllib.request
import urllib.parse
from urllib.parse import quote
import arcpy
import chardet
import string

cos=[rxxx关厂有限公司,
rxxx铝业有限公司]


time.sleep(0.5)

headers = {
    #‘User-Agent‘:‘Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4 Safari/605.1.15‘,
    #‘cookie‘:‘UM_distinctid=174283c5fa2357-020237e9668302-3323766-1fa400-174283c5fa3cb0; cna=ldDJF56cDDoCAbfQBooWogHr; _uab_collina=159840288725754455893877; passport_login=MTMwMzgwNjU3LGFtYXBfMTM3NzA3NzQyNTVBa1pXQVZFaGosZHJhaGhyZmd6dXp4djVieGtqdHBmcXNucDM0Y2c1amUsMTYwMTQzODIxMixPRGt4WmpVNU1tSmhNalV3T0dSbE9HTXhNRFpoWXpnek1EUmtPREF4WmpJPQ%3D%3D; dev_help=CO33CV6sTUkqYSlLAInVA2MwZjAzNGE0ZjFkYWYxZTE3NTljMmU2MjEyM2MwZmJlMmM5YTIzZWYwYjY3Zjg3ZDZhNmJkZDVlNjEyNGRhYjbKWtIPA1hn2opztyf7Gvib40X9qEGRRBVCMmq%2Fi%2BSj6ee39pqM3BF9ihbId%2FWsVLjNeAV7a2rKA%2FsqK2Ofst2eZDAYtSYE1Ae7q4VGpBF7DoSU3KFea0S3IFDbGZeRhUt6sxcXuSRhWPP6dJ06VmgK; xlly_s=1; x-csrf-token=a6a743c68ab75189ea27d03c285f2282; CNZZDATA1255626299=195401161-1598401733-%7C1603237083; gray_auth=2; tfstk=cjz5Ie_wYLv5Rxjez71qayj60aQLPOse1XsSE7ZRyvolTLIJbATCiELZCjRuxpLxXj1..; l=eBxHAGTeOYRlAvcFB9CQnurza77TeJdb80wUmNbMiIEz4jXGGMGB7ox7FccYKju5KuQMAb_hnsNMi3-wPvU8BPTpsyC2mccTbDtFAVIr3dTh.; isg=BO3sONjKTsPXaCplLuYuTj2n_IlnSiEcPGF-ky-9kwTzppVYyZq37BYwkHpAJjnU‘,
    Connection: keep-alive,
    # ‘Host‘: ‘www.amap.com‘,
    # ‘If-None-Match‘: ‘W/"a6f-OGfp0nb5B5X3sJcwBM9imldbfow"‘,
    #‘Referer‘: ‘https://www.amap.com/search?query=%E4%B8%9C%E5%9F%8E%E8%93%9D%E6%B9%BE&city=340500&geoobj=118.49715%7C31.545979%7C118.500791%7C31.551301&zoom=17.5‘,
    # ‘Sec-Fetch-Mode‘: ‘cors‘,
    # ‘Sec-Fetch-Site‘: ‘same-origin‘,
    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36,
    Control:"no-cach"
}

so_url=rhttps://xxx/newapi?d=pc&brand_cpc=on&keyword={0}&cityname=%E6%B8%85%E8%BF%9C&city=0763&cityid=441800&batch=1&number=10&citysuggestion=true&qii=true&region_id=&map_cbc=on&scheme=https&ext=&regionType=&sid=1000&mobile=1&from_city_card=0&address_aggregation=1&shuidixy=1&guid=239254294.938357017657250400.1598403417841.7048&near_bus=1&p=year&poirank=on&cpc_abv=s1&map_level=11&browser_size=1165,905&screen_size=1920,1200&screen_pixel_ratio=1&_=1619420699693

# so_url=r‘https://xxx/newapi?d=pc&brand_cpc=on&keyword=%E5%B9%BF%E4%B8%9C%E5%8C%97%E6%B1%9F%E5%BC%80%E5%85%B3%E5%8E%82%E6%9C%89%E9%99%90%E5%85%AC%E5%8F%B8&cityname=%E6%B8%85%E8%BF%9C&city=0763&cityid=441800&batch=1&number=10&citysuggestion=true&qii=true&region_id=&map_cbc=on&scheme=https&ext=&regionType=&sid=1000&mobile=1&from_city_card=0&address_aggregation=1&shuidixy=1&guid=239254294.938357017657250400.1598403417841.7048&near_bus=1&p=year&poirank=on&cpc_abv=s1&map_level=11&browser_size=1165,905&screen_size=1920,1200&screen_pixel_ratio=1&_=1619420699693‘

spatialref=arcpy.SpatialReference(4326)
arcpy.env.workspace = rE:\test\GaoxinQiye.gdb 
fc=rcos
cur2 = arcpy.da.InsertCursor(fc, [SHAPE@,primaryid,    adcode,    cityid,    address,    x,    y,    
name,name2,    area,    company_type,    business_scope,    legal_person,    province,    suspend_tips,    city]) 

x=0.0
y=0.0
primaryid=‘‘
adcode=‘‘
cityid=‘‘
address=‘‘
data_from=‘‘
name=‘‘
area=‘‘
company_type=‘‘
business_scope=‘‘
province=‘‘
suspend_tips=‘‘
legal_person=‘‘
city=‘‘

count=0
for name2 in cos:
    print(name2)
    url=so_url.format(name2)
    req_url = quote(url, safe=string.printable)

    response = urllib.request.urlopen(req_url)
    the_page = response.read().decode(utf-8)
    result = json.loads(the_page)
    response.close()

    x=0.0
    y=0.0
    primaryid=‘‘
    adcode=‘‘
    cityid=‘‘
    address=‘‘
    data_from=‘‘
    name=‘‘
    area=‘‘
    company_type=‘‘
    business_scope=‘‘
    province=‘‘
    legal_person=‘‘
    suspend_tips=‘‘
    city=‘‘

    x=float(result[poi][0][x])
    y=float(result[poi][0][y])
    point = arcpy.Point(x,y)

    if primaryid in result[poi][0]:
        primaryid=result[poi][0][primaryid]
    if cityid in result[poi][0]:
        cityid=result[poi][0][cityid]
    adcode=result[poi][0][adcode]
    if ‘address‘ in result[‘poi‘][0]:
        address=result[poi][0][address]
    elif addr in result[poi][0]:
        address=result[poi][0][addr]
    data_from=‘‘
    
    name=result[poi][0][name]
    area=result[poi][0][area]
    if suspend_tips in result[poi][0]:
        suspend_tips=result[poi][0][suspend_tips]
    if detail in result[poi][0]:
        legal_person=result[poi][0][detail][legal_person]
        company_type=result[poi][0][detail][company_type]
        business_scope=result[poi][0][detail][business_scope]

    if city in result[poi][0]:
        city=result[poi][0][city]

    cur2.insertRow([point, primaryid,    adcode,    cityid,    address,    x,    y,    name, name2,    area,    company_type,    business_scope,    legal_person,    province,    suspend_tips,    city])
    
    count+=1
    time.sleep(0.5)
del cur2

 

python3+获取地图高新企业坐标

标签:shu   mac   cti   bmc   zoom   tin   company   gecko   -o   

原文地址:https://www.cnblogs.com/yansc/p/14705674.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!