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              |
    +-------------------------+----------------------------+
    


  • 相关阅读:
    Xml---->JAXP DOM解析
    java(web)相对路径,绝对路径
    重定向与转发
    struts2之限制文件上传类型
    Struts2之文件上传上限
    Struts2之result中标准结果代码
    struts2之指定处理的请求后缀
    File.rename操作后,获取文件的名称,输出的名称仍为之前的名称
    硬盤掛載
    Java应用打包后运行需要注意编码问题 .
  • 原文地址:https://www.cnblogs.com/blfshiye/p/4660505.html
Copyright © 2011-2022 走看看