Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
303 views
in Technique[技术] by (71.8m points)

ruby - Rails crawler test loop itereation dosen'r work as expected

Hello I'm trying to make the crawler read the pages by multiples of 16 (0,16,32 so goes on) but in this test I get stuck in zero only, I know it's basic but I'm an starter in a intership, so please be kind with me. Here's the method:

puts "Crowling #{self.class} on page #{page}" #0
    
def crawl(url, operation, category)
  page = 0
  pages= 1
  while page < pages do
    puts "Crowling #{self.class} on page #{page}"
    verdi_page = (page * 16) - 16
    html = request(url, verdi_page)
    pages = parse_pages(html).max if page == 1
    page_properties = parse_properties(html, operation: operation, category:category)
    break if page_properties.empty?
    properties += page_properties
    page += 1
    sleep(rand(1..5)) unless Rails.env.test?
  end
end

Thanks in advance!

Terminal screenshot: https://imgur.com/a/429UPCs

question from:https://stackoverflow.com/questions/65644471/rails-crawler-test-loop-itereation-dosenr-work-as-expected

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...