Class: LinkedinScraper::Linkedin
- Inherits:
-
Object
- Object
- LinkedinScraper::Linkedin
- Defined in:
- lib/linkedin/linkedin.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Total number of profile’s connection e.g “44”.
-
#contact_for ⇒ Object
Purposes for which profile can be contacted to (if provided).
-
#current_company ⇒ Object
Current company of profile e.g “Pajama Labs”.
-
#current_job_description ⇒ Object
Current job description as available on linkedin.
-
#current_title ⇒ Object
Current title of profile e.g “Ceo”.
-
#education ⇒ Object
Schools profile has attended.
-
#experience ⇒ Object
Experience description if mentioned.
-
#full_name ⇒ Object
Full name of profile e.g “John Smith”.
-
#groups ⇒ Object
Groups a profile is associated with.
-
#industry ⇒ Object
All companies including current and past.
-
#linkedin_url ⇒ Object
Linkedin url of profile e.g “www.linkedin.com/pub/in/john+smith”.
-
#location ⇒ Object
Current location of profile “San Fransisco”.
-
#past_company ⇒ Object
Past companies of profile e.g “Google, Inc”.
-
#past_title ⇒ Object
Past title of profile e.g “VP Business”.
-
#recommendation ⇒ Object
Total number of profile’s recommendation e.g “44”.
-
#summary ⇒ Object
Profile’s summary as available on linkedin.
-
#websites ⇒ Object
Websites associated with Profile.
Instance Method Summary collapse
- #data(page) ⇒ Object
-
#get_profile_data(options) ⇒ Object
Get data of the required profile.
-
#initialize ⇒ Linkedin
constructor
Initializes mechnaize.
Constructor Details
#initialize ⇒ Linkedin
Initializes mechnaize
42 43 44 |
# File 'lib/linkedin/linkedin.rb', line 42 def initialize @agent = Mechanize.new { |agent| agent.user_agent_alias = USER_AGENTS.sample } end |
Instance Attribute Details
#connection ⇒ Object
Total number of profile’s connection e.g “44”
21 22 23 |
# File 'lib/linkedin/linkedin.rb', line 21 def connection @connection end |
#contact_for ⇒ Object
Purposes for which profile can be contacted to (if provided)
37 38 39 |
# File 'lib/linkedin/linkedin.rb', line 37 def contact_for @contact_for end |
#current_company ⇒ Object
Current company of profile e.g “Pajama Labs”
15 16 17 |
# File 'lib/linkedin/linkedin.rb', line 15 def current_company @current_company end |
#current_job_description ⇒ Object
Current job description as available on linkedin
17 18 19 |
# File 'lib/linkedin/linkedin.rb', line 17 def current_job_description @current_job_description end |
#current_title ⇒ Object
Current title of profile e.g “Ceo”
11 12 13 |
# File 'lib/linkedin/linkedin.rb', line 11 def current_title @current_title end |
#education ⇒ Object
Schools profile has attended
35 36 37 |
# File 'lib/linkedin/linkedin.rb', line 35 def education @education end |
#experience ⇒ Object
Experience description if mentioned
29 30 31 |
# File 'lib/linkedin/linkedin.rb', line 29 def experience @experience end |
#full_name ⇒ Object
Full name of profile e.g “John Smith”
7 8 9 |
# File 'lib/linkedin/linkedin.rb', line 7 def full_name @full_name end |
#groups ⇒ Object
Groups a profile is associated with
31 32 33 |
# File 'lib/linkedin/linkedin.rb', line 31 def groups @groups end |
#industry ⇒ Object
All companies including current and past
27 28 29 |
# File 'lib/linkedin/linkedin.rb', line 27 def industry @industry end |
#linkedin_url ⇒ Object
Linkedin url of profile e.g “www.linkedin.com/pub/in/john+smith”
9 10 11 |
# File 'lib/linkedin/linkedin.rb', line 9 def linkedin_url @linkedin_url end |
#location ⇒ Object
Current location of profile “San Fransisco”
23 24 25 |
# File 'lib/linkedin/linkedin.rb', line 23 def location @location end |
#past_company ⇒ Object
Past companies of profile e.g “Google, Inc”
33 34 35 |
# File 'lib/linkedin/linkedin.rb', line 33 def past_company @past_company end |
#past_title ⇒ Object
Past title of profile e.g “VP Business”
13 14 15 |
# File 'lib/linkedin/linkedin.rb', line 13 def past_title @past_title end |
#recommendation ⇒ Object
Total number of profile’s recommendation e.g “44”
25 26 27 |
# File 'lib/linkedin/linkedin.rb', line 25 def recommendation @recommendation end |
#summary ⇒ Object
Profile’s summary as available on linkedin
19 20 21 |
# File 'lib/linkedin/linkedin.rb', line 19 def summary @summary end |
#websites ⇒ Object
Websites associated with Profile
39 40 41 |
# File 'lib/linkedin/linkedin.rb', line 39 def websites @websites end |
Instance Method Details
#data(page) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/linkedin/linkedin.rb', line 77 def data page self.full_name = li_full_name(page) self.linkedin_url = page.uri.to_s self.current_title = li_current_title(page) self.past_title = li_past_title(page) self.current_company = li_current_companies(page) self.current_job_description = li_current_job_description(page) self.summary = li_summary(page) self.connection = li_connection(page) self.location = li_location(page) self.recommendation = li_recommendation(page) self.industry = li_current_companies(page) + li_past_companies(page) self.experience = li_experience(page) self.groups = li_groups(page) self.past_company = li_past_companies(page) self.education = li_education(page) self.contact_for = li_contact_for(page) self.websites = li_websites(page) end |
#get_profile_data(options) ⇒ Object
Get data of the required profile
options contains the key :name *Required :name - name of profile/contact e.g “John Smith” options contains the key :company *Required :company - current or past company of profile/contact e.g “Google” options contains the key :country *Optional (see list of supported countries in Readme) :country - preferred country of profile to be found in
Raises error if profile is not found or does not exist in linkedin or is not public profile Raises error if :name or :company or both are not defined Returns self
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/linkedin/linkedin.rb', line 58 def get_profile_data @options = raise "TypeError", "Invalid Arguments" unless .is_a?(Hash) argument_error("name") unless .has_key?(:name) argument_error("company") unless .has_key?(:company) query = build_query duck = LinkedinScraper::DuckDuckGo.new(query: query) results = duck.search raise "No Profile, Profile not found or does not exist" if results.empty? page = get_li_page(results[0]) raise "No Profile, Profile not found or does not exist" unless page if verify_profile(@options[:name], @options[:company], page) self.data page return self else raise "No Profile, Profile not found or does not exist" end end |