Class: IdsPlease::Grabbers::Mailru

Inherits:
Base
  • Object
show all
Defined in:
lib/ids_please/grabbers/mailru.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

Constructor Details

This class inherits a constructor from IdsPlease::Grabbers::Base

Instance Method Details



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ids_please/grabbers/mailru.rb', line 7

def grab_link
  @page_source  ||= open(link).read.encode('utf-8')
  uid_url         = "http://appsmail.ru/platform/#{link.split('/')[-2..-1].join('/')}"
  @network_id     = JSON.parse(open(uid_url).read)['uid']
  @username, type = get_name_and_type(link)
  @avatar         = find_by_regex(/profile__avatar" src="([^"]+)/)
  @display_name   = find_by_regex(/h1.+title="([^"]+)/)
  @display_name   = CGI.unescapeHTML(@display_name) if @display_name
  @data = {
    type: type,
    description: find_by_regex(/profile__content_mainInfo" title="([^"]+)/)
  }
  @data[:description] = CGI.unescapeHTML(@data[:description]) if @data[:description]
  self
rescue => e
  record_error __method__, e.message
  return self
end