lib/krawler.rb in krawler-1.0.4 vs lib/krawler.rb in krawler-1.0.5
- old
+ new
@@ -1,11 +1,11 @@
require 'krawler/version'
require 'mechanize'
require 'timeout'
require 'uri'
require 'thread'
-
+require 'pry'
module Krawler
class Base
def initialize(url, options)
@@ -65,9 +65,12 @@
threads.each { |t| t.join }
end
def crawl_page(link, agent)
+link = link.to_s.gsub(/per_page=36/, '')
+link = link =~ /(.*)(page=\d)/ ? "#{$1}per_page=36&#{$2}" : "#{link}?per_page=36&page=1"
+
@crawled_links << link
begin
start = Time.now
page = agent.get(link, [], nil, @headers)