Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing LinkedIn public pages using Python

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.

like image 937
Ankush Shah Avatar asked May 24 '14 09:05

Ankush Shah


People also ask

How do I use LinkedIn API in Python?

HTTP API exampleSet LINKEDIN_API_KEY and LINKEDIN_API_SECRET, configure your app to redirect to http://localhost:8080/code, then execute: http_api.py. Visit http://localhost:8080 in your browser, curl or similar. A tab in your browser will open up, give LinkedIn permission there.

How do I scrape LinkedIn selenium?

Log into your LinkedIn accountselenium import webdriver import BeautifulSoup time # Creating a webdriver instance webdriver. Chrome("Enter-Location-Of-Your-Web-Driver") # This instance will be used to log into LinkedIn # Opening linkedIn's login page. ("https://linkedin.com/uas/login") # waiting for the page to load.

Which tool allows us to scrape profiles from Google and LinkedIn?

Captain Data allows you to scrape LinkedIn and extract data from almost any website and especially LinkedIn or LinkedIn Sales Navigator. The tool offers Sales and Marketing teams ready-to-use workflows to automate their prospecting: find leads, enrich them, address them in a hyper-personalized manner.


1 Answers

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.

like image 102
Ankush Shah Avatar answered Oct 12 '22 23:10

Ankush Shah