Skip to content

Instantly share code, notes, and snippets.

@sagzy
Created April 16, 2016 10:23
Show Gist options
  • Save sagzy/c585a00c81e2659f25280438dbe211f8 to your computer and use it in GitHub Desktop.
Save sagzy/c585a00c81e2659f25280438dbe211f8 to your computer and use it in GitHub Desktop.
Scrap skills from a Linkedin profile
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