Class: ScrapeUnblocker::PageResult

Inherits:
Object
  • Object
show all
Defined in:
lib/scrapeunblocker/parsed_page.rb

Overview

HTML plus the cookies and proxy that served it (#get_page_with_cookies).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(html:, cookies:, proxy:, raw:) ⇒ PageResult

Returns a new instance of PageResult.



37
38
39
40
41
42
# File 'lib/scrapeunblocker/parsed_page.rb', line 37

def initialize(html:, cookies:, proxy:, raw:)
  @html = html
  @cookies = cookies
  @proxy = proxy
  @raw = raw
end

Instance Attribute Details

#cookiesObject (readonly)

Returns the value of attribute cookies.



35
36
37
# File 'lib/scrapeunblocker/parsed_page.rb', line 35

def cookies
  @cookies
end

#htmlObject (readonly)

Returns the value of attribute html.



35
36
37
# File 'lib/scrapeunblocker/parsed_page.rb', line 35

def html
  @html
end

#proxyObject (readonly)

Returns the value of attribute proxy.



35
36
37
# File 'lib/scrapeunblocker/parsed_page.rb', line 35

def proxy
  @proxy
end

#rawObject (readonly)

Returns the value of attribute raw.



35
36
37
# File 'lib/scrapeunblocker/parsed_page.rb', line 35

def raw
  @raw
end

Class Method Details

.from_hash(payload) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/scrapeunblocker/parsed_page.rb', line 44

def self.from_hash(payload)
  new(
    html: payload["html"] || payload["page_source"] || payload["content"],
    cookies: payload["cookies"],
    proxy: payload["proxy"] || payload["proxy_address"],
    raw: payload
  )
end