怎么做Linkedin人在python中搜索api?

时间:2015-02-27 12:26:32

标签: python json csv linkedin

我正在尝试使用关键字.....找到linkdein中的人与他们的个人资料数据。

我遵循以下文件。

https://github.com/ozgur/python-linkedin

People Search API会返回有关人员的信息。它允许您实现在LinkedIn.com右上方框中搜索“人物”时显示的大部分内容。您可以从这里获得更多信息。

application.search_profile(selectors=[{'people': ['first-name', 'last-name']}], params={'keywords': 'apple microsoft'})

# Search URL is https://api.linkedin.com/v1/people-search:(people:(first-name,last-name))?keywords=apple%20microsoft

{u'people': {u'_count': 10,
      u'_start': 0,
      u'_total': 2,
      u'values': [
       {u'firstName': u'John', u'lastName': 'Doe'},
       {u'firstName': u'Jane', u'lastName': u'Doe'}
      ]}}

下面的代码我试过了。我收到了我的个人资料详情。 但我想根据关键字搜索用户。 application.search_profile函数给我错误。

我搜索过的People_search python文档,但我找不到。

from linkedin import linkedin
from oauthlib import *


CONSUMER_KEY = 'XXXXX'
CONSUMER_SECRET = 'XXXXX'
USER_TOKEN = 'XXXXX'
USER_SECRET = 'XXXXX'
RETURN_URL = 'http://localhost:8000'

authentication = linkedin.LinkedInDeveloperAuthentication(CONSUMER_KEY, CONSUMER_SECRET, 
                                                      USER_TOKEN, USER_SECRET, 
                                                      RETURN_URL, linkedin.PERMISSIONS.enums.values())


application = linkedin.LinkedInApplication(authentication)

g = application.get_profile()
print g

Output : {u'lastName': u'Gandhi', u'siteStandardProfileRequest': {u'url': u'https://www.linkedin.com/profile/view?id=184546922'}, u'id': u'izHKd17BFS', u'firstName': u'Karamchand'}  


application.search_profile(selectors=[{'people': ['first-name', 'last-name']}], params={'keywords': 'apple microsoft'})


while running I am getting below error.

Traceback (most recent call last):
  File "E:/Linkedin Scraping/Linkedin", line 22, in <module>
    application.search_profile(selectors=[{'people': ['first-name', 'last-name']}], params={'keywords': 'apple microsoft'})
  File "C:\Python27\lib\site-packages\linkedin\linkedin.py", line 189, in search_profile
    raise_for_error(response)
  File "C:\Python27\lib\site-packages\linkedin\utils.py", line 63, in raise_for_error
    raise LinkedInError(message)
LinkedInError: 403 Client Error: Forbidden: Unknown Error

我也试过休息控制台。 https://api.linkedin.com/v1/people-search:(people:(first-name,last-name,headline,industry,email-address))?keywords=client%20engagement

我想要所有37934结果,我想将所有这些结果存储在csv中? 在那里我得到这样的结果。

<?xml version="1.0" encoding="UTF-8"?>
<people-search>
  <people total="37934" count="10" start="0">
    <person>
      <first-name>Srinivas</first-name>
      <last-name>Manam</last-name>
      <headline>Sr.Manager - Client Engagement</headline>
      <industry>Information Technology and Services</industry>
    </person>
    <person>
      <first-name>*Anand</first-name>
      <last-name>Kumar (Andy)*</last-name>
      <headline>Assistant Manager - Client Engagement at Magna Infotech Ltd</headline>
      <industry>Information Technology and Services</industry>
    </person>
    <person>
      <first-name>Kailash</first-name>
      <last-name>Kulkarni.</last-name>
      <headline>Manager - IT Staffing Business Development & Delivery</headline>
      <industry>Computer Software</industry>
    </person>
    <person>
      <first-name>Ramesh</first-name>
      <last-name>A</last-name>
      <headline>Asst.Manager- Client Engagement (TAG)</headline>
      <industry>Human Resources</industry>
    </person>
</people-search>

如何获取所有37934结果并将所有结果存储在csv中?我是python的新手。我在使用它时面临困难吗?

0 个答案:

没有答案