Class: UrlExpander::Expanders::Shorl

Inherits:
Scrape
  • Object
show all
Defined in:
lib/url_expander/expanders/scrape/shorl.rb

Overview

Expand shorl.com URLS Usage: UrlExpander::Client.expand(“shorl.com/nigekohalenu”)

Defined Under Namespace

Classes: Request

Constant Summary collapse

PATTERN =
%r'(http://shorl\.com(/[\w/]+))'

Instance Attribute Summary collapse

Attributes inherited from Scrape

#long_url, #parttern

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(short_url = "", options = {}) ⇒ Shorl

Returns a new instance of Shorl.



12
13
14
15
# File 'lib/url_expander/expanders/scrape/shorl.rb', line 12

def initialize(short_url="", options={})
  @parent_klass = self.class
  super(short_url, options)
end

Instance Attribute Details

#parent_klassObject (readonly)

Returns the value of attribute parent_klass.



10
11
12
# File 'lib/url_expander/expanders/scrape/shorl.rb', line 10

def parent_klass
  @parent_klass
end

#xpathObject (readonly)

Returns the value of attribute xpath.



10
11
12
# File 'lib/url_expander/expanders/scrape/shorl.rb', line 10

def xpath
  @xpath
end

Class Method Details

.scrape_url(html) ⇒ Object

How to scarpe the url from a shorl html document



19
20
21
22
# File 'lib/url_expander/expanders/scrape/shorl.rb', line 19

def self.scrape_url(html)
  doc = Hpricot(html)
  doc.at('/html/body/div[3]/p/a').attributes["href"]
end