Class: Linkedin::Profile

Inherits:
Object
  • Object
show all
Includes:
GetRelated, ProxyManager
Defined in:
lib/linkedin.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from GetRelated

#addPointsToProfile, #downloadRelated, #fullProfileList, #getList, #getRelatedProfiles, #relScore

Constructor Details

#initialize(url, driver, curhops, proxylist, usedproxies, use_proxies_li) ⇒ Profile

Returns a new instance of Profile.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/linkedin.rb', line 9

def initialize(url, driver, curhops, proxylist, usedproxies, use_proxies_li)
  @linkedin_url = url
  @curhops = curhops
  @proxylist = proxylist
  @usedproxies = usedproxies
  
  # Add attributes to list
  ATTRIBUTES.push(
    "related_people",
    "profile_url",
    "timestamp",
    "degree",
    "pic_path")

  # Get page
  @driver = driver
  @page = Nokogiri::HTML(getPage(url, @driver, nil, 5, use_proxies_li).page_source)
  sleep(10)
end

Class Method Details

.get_profile(url, driver, curhops, proxylist, usedproxies, use_proxies_li) ⇒ Object



30
31
32
33
34
# File 'lib/linkedin.rb', line 30

def self.get_profile(url, driver, curhops, proxylist, usedproxies, use_proxies_li)
  Linkedin::Profile.new(url, driver, curhops, proxylist, usedproxies, use_proxies_li)
rescue => e
  puts e
end

Instance Method Details

#degreeObject

Get the number of hops out where profile appears



52
53
54
# File 'lib/linkedin.rb', line 52

def degree
  @degree ||= @curhops
end

#pic_pathObject

Download the profile picture



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/linkedin.rb', line 57

def pic_path
  if picture
    # Get path
    dir = "public/uploads/pictures/"
    full_path = dir+picture.split("/").last.chomp.strip

    # Get file
    `wget -P #{dir} #{picture}` if !File.file?(full_path)
    return full_path
  end
end

#profile_urlObject

Similar to linkedin_url



42
43
44
# File 'lib/linkedin.rb', line 42

def profile_url
  @profile_url ||= @linkedin_url
end

Gets “people also viewed list” form profile sidebar



37
38
39
# File 'lib/linkedin.rb', line 37

def related_people
  @related_people ||= getList(@page)
end

#timestampObject

Get the time the profile was scraped



47
48
49
# File 'lib/linkedin.rb', line 47

def timestamp
  @timestamp ||= Time.now
end