Class: IdsPlease::Grabbers::GooglePlus
- Inherits:
-
Base
- Object
- Base
- IdsPlease::Grabbers::GooglePlus
show all
- Defined in:
- lib/ids_please/grabbers/google_plus.rb
Instance Attribute Summary
Attributes inherited from Base
#avatar, #counts, #data, #display_name, #link, #network_id, #page_source, #username
Instance Method Summary
collapse
Methods inherited from Base
#errors, #find_by_regex, #initialize, #inspect, interact, #record_error, #to_h, #to_s
Instance Method Details
#find_avatar ⇒ Object
33
34
35
36
37
38
|
# File 'lib/ids_please/grabbers/google_plus.rb', line 33
def find_avatar
"https:#{find_by_regex(/guidedhelpid="profile_photo"><img src="([^"]+)"/)}"
rescue => e
record_error __method__, e.message
return nil
end
|
#find_description ⇒ Object
54
55
56
57
58
59
|
# File 'lib/ids_please/grabbers/google_plus.rb', line 54
def find_description
find_by_regex(/name="Description" content="([^"]+)">/).encode('utf-8')
rescue => e
record_error __method__, e.message
return nil
end
|
#find_display_name ⇒ Object
40
41
42
43
44
45
|
# File 'lib/ids_please/grabbers/google_plus.rb', line 40
def find_display_name
find_by_regex(/og:title" content="([^"]+)"/).gsub(' - Google+', '')
rescue => e
record_error __method__, e.message
return nil
end
|
#find_followers ⇒ Object
61
62
63
64
65
66
67
68
|
# File 'lib/ids_please/grabbers/google_plus.rb', line 61
def find_followers
if followers = find_by_regex(/">([^"]+)<\/span> followers</)
followers.tr(',', '').to_i
end
rescue => e
record_error __method__, e.message
return nil
end
|
#find_network_id ⇒ Object
26
27
28
29
30
31
|
# File 'lib/ids_please/grabbers/google_plus.rb', line 26
def find_network_id
find_by_regex(/oid="(\d+)"/)
rescue => e
record_error __method__, e.message
return nil
end
|
#find_username ⇒ Object
47
48
49
50
51
52
|
# File 'lib/ids_please/grabbers/google_plus.rb', line 47
def find_username
"+#{find_by_regex(/"https:\/\/plus.google.com\/\+(.+?)"/)}"
rescue => e
record_error __method__, e.message
return nil
end
|
#find_views ⇒ Object
70
71
72
73
74
75
76
77
|
# File 'lib/ids_please/grabbers/google_plus.rb', line 70
def find_views
if views = find_by_regex(/">([^"]+)<\/span> views</)
views.tr(',', '').to_i
end
rescue => e
record_error __method__, e.message
return nil
end
|
#grab_link ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/ids_please/grabbers/google_plus.rb', line 5
def grab_link
@network_id = find_network_id
@avatar = find_avatar
@display_name = find_display_name
@username = find_username
@counts = {
followers: find_followers,
views: find_views
}.delete_if { |_k, v| v.nil? }
@data = {
description: find_description
}.delete_if { |_k, v| v.nil? }
self
rescue => e
record_error __method__, e.message
return self
end
|