linkedindata 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/getrelated.rb +9 -4
- data/lib/linkedindata.rb +22 -3
- data/lib/parseprofile.rb +4 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ce0c9ca0b41f4135c0bac28948b0c79b0fc1f4f
|
4
|
+
data.tar.gz: e4b25773439dca11aa6db67b725b2a4d7e827c2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2598ede15cff3d41303c6bd0745099ed23ffb0b7375970c1987d17b5621ae0c36fddf731468fcc9b889670a75e46bae8b6b30a85bc7bcdf2ce7c772954aa71d7
|
7
|
+
data.tar.gz: 7e7e3ffbe4619a783b1315a78157986c20416bc6f07f9ac084f8ece34020f9210292153ba7669a3d7f5cb26e05e9bd7e36b451cf9c7365227ba710cb3f83d091
|
data/lib/getrelated.rb
CHANGED
@@ -10,15 +10,20 @@ class GetRelated
|
|
10
10
|
|
11
11
|
# Get the list of names of related people
|
12
12
|
def getList
|
13
|
-
html = Nokogiri::HTML(open(@url))
|
14
|
-
|
13
|
+
html = Nokogiri::HTML(open(@url.gsub("http", "https")))
|
14
|
+
|
15
15
|
if html
|
16
16
|
namelist = Array.new
|
17
17
|
|
18
18
|
# Go through each person
|
19
19
|
html.css("div.insights-browse-map").each do |d|
|
20
|
-
d.css("
|
21
|
-
|
20
|
+
if d.css("h3").text == "People Also Viewed"
|
21
|
+
d.css("li").each do |l|
|
22
|
+
temphash = Hash.new
|
23
|
+
temphash[:name] = l.css("h4").text
|
24
|
+
temphash[:url] = l.css("a")[0]['href']
|
25
|
+
namelist.push(temphash)
|
26
|
+
end
|
22
27
|
end
|
23
28
|
end
|
24
29
|
|
data/lib/linkedindata.rb
CHANGED
@@ -12,6 +12,7 @@ class LinkedinData
|
|
12
12
|
@input = input
|
13
13
|
@output = Array.new
|
14
14
|
@startindex = 10
|
15
|
+
@numhops = todegree
|
15
16
|
end
|
16
17
|
|
17
18
|
# Searches for profiles on Google
|
@@ -39,7 +40,7 @@ class LinkedinData
|
|
39
40
|
if saveurl[1]
|
40
41
|
url = saveurl[1].split("&")
|
41
42
|
begin
|
42
|
-
scrape(url[0])
|
43
|
+
scrape(url[0], 0)
|
43
44
|
rescue
|
44
45
|
end
|
45
46
|
end
|
@@ -61,7 +62,7 @@ class LinkedinData
|
|
61
62
|
end
|
62
63
|
|
63
64
|
# Scrapes profile
|
64
|
-
def scrape(url)
|
65
|
+
def scrape(url, curhops)
|
65
66
|
# Download profile and rescue on error
|
66
67
|
begin
|
67
68
|
url.gsub!("https", "http")
|
@@ -71,7 +72,7 @@ class LinkedinData
|
|
71
72
|
|
72
73
|
# Parse profile if returned
|
73
74
|
if profile
|
74
|
-
p = ParseProfile.new(profile, url)
|
75
|
+
p = ParseProfile.new(profile, url, curhops)
|
75
76
|
@output.concat(p.parse)
|
76
77
|
end
|
77
78
|
end
|
@@ -79,6 +80,24 @@ class LinkedinData
|
|
79
80
|
# Gets all data and returns in JSON
|
80
81
|
def getData
|
81
82
|
search
|
83
|
+
|
84
|
+
# Get related profiles
|
85
|
+
@numhops.times do
|
86
|
+
@output.each do |o|
|
87
|
+
if o[:degree] < @numhops
|
88
|
+
|
89
|
+
if o[:related_people]
|
90
|
+
o[:related_people].each do |i|
|
91
|
+
if @output.select { |obj| obj[:name] == i[:name]}.empty?
|
92
|
+
scrape(i[:url], o[:degree]+1)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
82
101
|
formatted_json = JSON.pretty_generate(@output)
|
83
102
|
return formatted_json
|
84
103
|
end
|
data/lib/parseprofile.rb
CHANGED
@@ -2,11 +2,12 @@ require 'json'
|
|
2
2
|
load 'getrelated.rb'
|
3
3
|
|
4
4
|
class ParseProfile
|
5
|
-
def initialize(profile, url)
|
5
|
+
def initialize(profile, url, curhops)
|
6
6
|
@profile = profile
|
7
7
|
@url = url
|
8
8
|
@output = Array.new
|
9
9
|
@related_people
|
10
|
+
@curhops = curhops
|
10
11
|
end
|
11
12
|
|
12
13
|
# Parse profile
|
@@ -54,7 +55,8 @@ class ParseProfile
|
|
54
55
|
:profile_url => @url,
|
55
56
|
:current => status,
|
56
57
|
:timestamp => Time.now,
|
57
|
-
:related_people => @related_people
|
58
|
+
:related_people => @related_people,
|
59
|
+
:degree => @curhops)
|
58
60
|
c.merge!(:pic_path => getPic)
|
59
61
|
return c
|
60
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linkedindata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- M. C. McGrath
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Scrapes all LinkedIn profiles including terms you specify.
|
14
14
|
email: shidash@shidash.com
|