Accessing LinkedIn Public Pages Using Python

I want to access my public LinkedIn page. The following code works on my local machine:

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) redirects somewhere and gets this html.

Also, when I try to use urllib2 on the heroku server:

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

This throws urllib2.HTTPError: HTTP Error 999: request rejected

Since I use virtualenv, all the libraries on my local machine are exactly the same as those installed on the heroku server. Does LinkedIn block HTTP requests from servers like Heroku? Any help / suggestions would be appreciated.

+6
source share
1 answer

As mentioned here , LinkedIn does not allow direct access. They have a blacklist of Heroku IP addresses, and the only way to access the data is to use their API.

+6
source

Source: https://habr.com/ru/post/969794/


All Articles