Python extracts connections from LinkedIn users

Source: Internet
Author: User

CODE:

#!/usr/bin/python #-*-Coding:utf-8-*-"Created on 2014-8-18@author:guaguastd@name:linkedin_connection_ retrieve.py ' # import loginfrom login import linkedin_login# import jsonimport jsonfrom prettytable import prettytable# A ccess to LinkedIn Apilinkedin_api = linkedin_login () connections = Linkedin_api.get_connections () Connections_data = R ' E : \eclipse\linkedin\dfile\linkedin_connections.json ' # Write connections into disk Filef = open (Connections_data, ' W ') F.write (Json.dumps (connections, indent=1)) F.close () # Read data from disk Fileconnections = 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 |+-------------------------+----------------------------+| Fly Yellow | Beijing city, China | | James Liao | San Francisco Bay Area | | Gerald Soparkar | San Francisco Bay Area | | Dimitrios Kouzis-loukas | Birmingham, Kingdom | | Xiaodong Xu | Beijing city, China | | Xinsong Li | China | | Tech Backyard | Chengdu, Sichuan, China | | Yan Super hu | Xingtai, Hebei, China | | Knox | Beijing city, China | | Zhang Jason | Beijing city, China | | Qu Sisyphus | States | | Honglin Zhang | Foshan, Guangdong, China | | Beyond Bzhou | States |+-------------------------+----------------------------+


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.