lib/page_rankr/ranks/alexa_us.rb in PageRankr-2.0.0 vs lib/page_rankr/ranks/alexa_us.rb in PageRankr-2.0.1
- old
+ new
@@ -4,11 +4,17 @@
module PageRankr
class Ranks
class AlexaUs
include Rank
+ # 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.
def xpath
- "//reach/@rank"
+ "//popularity[contains(@url, '#{@site.domain}')]/../reach/@rank"
end
def request
@request ||= Typhoeus::Request.new("http://data.alexa.com/data",
:params => {:cli => 10, :dat => "snbamz", :url => @site.to_s})
\ No newline at end of file