使用Python访问LinkedIn公共页面 [英] Accessing LinkedIn public pages using Python

查看:148
本文介绍了使用Python访问LinkedIn公共页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想访问我的公开LinkedIn页面。在我的本地机器上,以下代码工作:

 导入请求
url =http://de.linkedin。 com / pub / ankush-shah / 73/9/982
html = requests.get(url).text
print html

它给出了我的个人资料的正确html。



但是当我在Heroku服务器上执行相同的代码时,我(猜)被重定向到某处并获得这个 html。



另外,当我尝试在heroku服务器上使用urllib2时:

  import urllib2 
url =http://de.linkedin.com/pub/ankush-shah/73/9/982
u = urllib2.urlopen(url)

这会引发 urllib2.HTTPError:HTTP错误999:请求拒绝



当我使用virtualenv时,本地机器上的所有库都与安装在heroku服务器上的库完全相似。 LinkedIn是否阻止来自像Heroku这样的服务器的HTTP请求?任何帮助/建议,将不胜感激。 999rel =noreferrer>这里,LinkedIn不允许直接访问。他们将Heroku的IP地址列入黑名单,访问数据的唯一方法是使用他们的API。

I want to access my publicly available LinkedIn page. On my local machine, following code works:

import requests
url = "http://de.linkedin.com/pub/ankush-shah/73/9/982"
html = requests.get(url).text
print html

And it gives the correct html of my profile.

But when I execute the same code on my Heroku server, I (guess) am redirected to somewhere and gets this html.

Also, when I try with urllib2 on the heroku server:

import urllib2
url = "http://de.linkedin.com/pub/ankush-shah/73/9/982"
u = urllib2.urlopen(url)

This throws an urllib2.HTTPError: HTTP Error 999: Request denied

As I am using virtualenv, all the libraries on my local machine are exactly similar to the one installed on heroku server. Does LinkedIn blocks HTTP requests from servers like Heroku? Any help/suggestions would be appreciated.

解决方案

As mention here, LinkedIn do not allow direct access. They have blacklisted Heroku's IP address and the only way to access the data is to use their APIs.

这篇关于使用Python访问LinkedIn公共页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆