zoukankan      html  css  js  c++  java
  • Python 摘录LinkedIn用户联系人

    CODE:

    #!/usr/bin/python 
    # -*- coding: utf-8 -*-
    
    '''
    Created on 2014-8-18
    @author: guaguastd
    @name: linkedin_connection_retrieve.py
    '''
    
    # import login
    from login import linkedin_login
    
    # import json
    import json
    from prettytable import PrettyTable
    
    # access to linkedin api
    linkedin_api = linkedin_login()
    
    connections = linkedin_api.get_connections()
    connections_data = r'E:eclipseLinkedIndfilelinkedin_connections.json'
    
    # Write connections into disk file
    f = open(connections_data, 'w')
    f.write(json.dumps(connections, indent=1))
    f.close()
    
    # Read data from disk file
    connections = json.loads(open(connections_data).read())
    
    # Print the connections
    #print json.dumps(connections, indent=1)
    pt = PrettyTable(field_names=['Name', 'Location'])
    pt.align = 'l'
    
    [pt.add_row((c['firstName'] + ' ' + c['lastName'], c['location']['name']))
     for c in connections['values']
         if c.has_key('location')]
    
    print pt

    RESULT:

    +-------------------------+----------------------------+
    | Name                    | Location                   |
    +-------------------------+----------------------------+
    | 飞 黄                   | Beijing City, China        |
    | James Liao              | San Francisco Bay Area     |
    | Gerald Soparkar         | San Francisco Bay Area     |
    | Dimitrios Kouzis-Loukas | Birmingham, United Kingdom |
    | Xiaodong Xu             | Beijing City, China        |
    | Xinsong Li              | China                      |
    | 科技 后院               | Chengdu, Sichuan, China    |
    | 彦超 胡                 | Xingtai, Hebei, China      |
    | 诺克 埃                 | Beijing City, China        |
    | Zhang Jason             | Beijing City, China        |
    | qu Sisyphus             | United States              |
    | 洪林 张                 | Foshan, Guangdong, China   |
    | beyond Bzhou            | United States              |
    +-------------------------+----------------------------+
    


  • 相关阅读:
    字母次数
    hdu 2051 Bitset(十进制到二进制)
    练习1升级
    实验一写能自动生成小学四则运算题目的程序
    TCP/IP bad check sum
    Lua GC 之 Ephemeron
    RHEL6下VNC安装和配置
    qpid安装
    关闭中国电信无线客户端自动更新
    Python GC
  • 原文地址:https://www.cnblogs.com/blfshiye/p/4660505.html
Copyright © 2011-2022 走看看