Class: PageRankr::Ranks::AlexaGlobal
- Inherits:
-
Object
- Object
- PageRankr::Ranks::AlexaGlobal
- Includes:
- PageRankr::Rank
- Defined in:
- lib/page_rankr/ranks/alexa_global.rb
Instance Attribute Summary
Attributes included from PageRankr::Rank
Instance Method Summary collapse
- #request ⇒ Object
-
#xpath ⇒ Object
Alexa may sometimes return a result for the incorrect site and thus it is necessary to check if the results returned are for the site we want.
Methods included from PageRankr::Rank
Instance Method Details
#request ⇒ Object
19 20 21 22 |
# File 'lib/page_rankr/ranks/alexa_global.rb', line 19 def request @request ||= Typhoeus::Request.new("http://data.alexa.com/data", :params => {:cli => 10, :dat => "snbamz", :url => @site.to_s}) end |
#xpath ⇒ Object
Alexa may sometimes return a result for the incorrect site and thus it is necessary to check if the results returned are for the site we want.
For example, slocourts.net returns results for ca.gov, presumably because www.slocourts.ca.gov redirects to slocourts.net. Clearly something is wrong with how Alexa handles this case and so in the event this happens we treat the results as if there were no results.
15 16 17 |
# File 'lib/page_rankr/ranks/alexa_global.rb', line 15 def xpath "//popularity[contains(@url, '#{@site.domain}')]/@text" end |