Created
April 16, 2016 10:23
-
-
Save sagzy/c585a00c81e2659f25280438dbe211f8 to your computer and use it in GitHub Desktop.
Scrap skills from a Linkedin profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'nokogiri' | |
require 'rest-client' | |
# Get skills listed in a Linkedin profile | |
# HTML structure specific, to be maintained. Last check on the 16/04/2016 | |
def get_skills_for_a_profile(profile) | |
skills = [] | |
profile.css('li.skill').each do |attr| | |
skills << "#{attr.text}" | |
end | |
skills | |
end | |
#Connect to a Linkedin profile using OpenSSL, get page content and an array of skills | |
profile_url = "https://www.linkedin.com/in/sgupta10" | |
response = RestClient::Resource.new(profile_url, | |
verifiy_ssl: OpenSSL::SSL::VERIFY_PEER).get | |
if response.code == 200 | |
profile = Nokogiri::HTML(response.body) | |
skills = get_skills_for_a_profile(profile) | |
print(skills) | |
else | |
print "Error : #{response.code}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment