Skip to content

Instantly share code, notes, and snippets.

@jimmybaker
Forked from anonymous/gist:468069
Created July 8, 2010 14:41
Show Gist options
  • Save jimmybaker/468093 to your computer and use it in GitHub Desktop.
Save jimmybaker/468093 to your computer and use it in GitHub Desktop.
desc "Fetch affiliate offers"
task :getoffers => :environment do
require 'mechanize'
agent = WWW::Mechanize.new
agent.get("http://odigger.com/Find-All-Affiliate-Programs")
total_number_of_pages = ..gram the total number of pages..
total_number_of_pages.to_i.times do |page_num|
agent.get("http://odigger.com/Find-All-Affiliate-Programs?&pg=#{page_num + 1}")
agent.page.search("td.left a").each do |offer|
Offer.create!(:name => offer.text.strip)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment