lib/page_rankr/index.rb in PageRankr-1.7.1 vs lib/page_rankr/index.rb in PageRankr-2.0.0
- old
+ new
@@ -1,14 +1,19 @@
require 'nokogiri'
require 'open-uri'
module PageRankr
- class Index
+ module Index
attr_reader :indexes
alias_method :tracked, :indexes
def initialize(site)
- @indexes = clean Nokogiri::HTML(open url(site)).at(xpath).to_s
+ @site = site
+ request.on_complete do |response|
+ html = Nokogiri::HTML(response.body)
+ @indexes = clean(html.at(xpath).to_s)
+ @indexes = nil if @indexes.zero?
+ end
end
def clean(backlink_count)
backlink_count.gsub(/[a-zA-Z,\s\(\)]/, '').to_i
end
\ No newline at end of file