Sha256: be26d478bc6e0cc62d27e73ecba32e8d0d890bc84778e84174952521e7fa77ab

Contents?: true

Size: 455 Bytes

Versions: 1

Compression:

Stored size: 455 Bytes

Contents

require 'open-uri'
require 'cgi'
require 'nokogiri'

module PageRankr
  class Ranks < Tracker
    class Compete < Rank
      def initialize(site)
        @rank = Nokogiri::HTML(open(url(site))).search(xpath).to_s.gsub(',', '').to_i
      end
      
      def xpath
        "//div[@id='rank']/div[@class='number value']/text()"
      end
      
      def url(site)
        "http://siteanalytics.compete.com/#{CGI.escape(site)}/"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
PageRankr-1.7.0 lib/page_rankr/ranks/compete.rb