首页 > 代码库 > Python 对LinkedIn用户联系人的地址进行地理编码

Python 对LinkedIn用户联系人的地址进行地理编码

CODE:

#!/usr/bin/python 
# -*- coding: utf-8 -*-

'''
Created on 2014-8-20
@author: guaguastd
@name: geocode_connection_bing.py
'''

from geopy import geocoders
import json

GEO_APP_KEY = ''
g = geocoders.Bing(GEO_APP_KEY)

# access to linkedin api
from login import linkedin_login
linkedin_api = linkedin_login()

connections = linkedin_api.get_connections()
connections_data = http://www.mamicode.com/r'E:/eclipse/LinkedIn/dfile/linkedin_connections.json'>
RESULT:

{u'United States': [Location(United States 39 27m 0.0s N, 98 57m 0.0s W)], 
u'Chengdu, Sichuan, China': [Location(Chengdu, Sichuan, China 30 40m 0.0s N, 104 5m 0.0s E)], 
u'Beijing City, China': [Location(Beijing, Beijing, China 39 54m 0.0s N, 116 23m 0.0s E)], 
u'China': [Location(China 36 33m 0.0s N, 103 59m 0.0s E)], 
u'San Francisco Bay Area': [Location(CA, United States 37 43m 0.0s N, 122 15m 0.0s W)], 
u'Foshan, Guangdong, China': [Location(Foshan, Guangdong, China 23 2m 0.0s N, 113 6m 0.0s E)], 
u'Xingtai, Hebei, China': [Location(Xingtai, Hebei, China 37 4m 0.0s N, 114 29m 0.0s E)], 
u'Birmingham, United Kingdom': [Location(Birmingham, England, United Kingdom 52 29m 0.0s N, 1 55m 0.0s W), Location(Birmingham, England, United Kingdom 52 27m 0.0s N, 1 43m 0.0s W), Location(Birmingham Airport, England, United Kingdom 52 27m 0.0s N, 1 44m 0.0s W), Location(Birmingham Business Park, England, United Kingdom 52 28m 0.0s N, 1 43m 0.0s W)]}