ruby - Scraping successive pages until the last page using Nokogiri and Mechanize -
i trying scrape multiple pages website. want scrape page, click on next, page, , repeat until hit end. wrote far:
page = agent.submit(form, form.buttons.first) #submitting form while lien = page.link_with(:text=>'next') # while have next link on page, keep scraping html_body = nokogiri::html(body) links = html_body.css('.list').xpath("//table/tbody/tr/td[2]/a[1]") links.each |link| purelink = link['href'] puts purelink[/codeclub=([^&]*)/].gsub('codeclub=', '') lien.click end end unfortunately, script keep on scraping same page in infinite loop... how can achieve want ?
i try this, replace lien.click page = lien.click.
Comments
Post a Comment