Skip to content

Instantly share code, notes, and snippets.

Created July 8, 2010 14:19
Show Gist options
  • Save anonymous/468069 to your computer and use it in GitHub Desktop.
Save anonymous/468069 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")
agent.page.search("td.left a").each do |offer|
Offer.create!(:name => offer.text.strip)
end
agent.get("http://odigger.com/Find-All-Affiliate-Programs?&pg=2")
agent.page.search("td.left a").each do |offer|
Offer.create!(:name => offer.text.strip)
end
agent.get("http://odigger.com/Find-All-Affiliate-Programs?&pg=3")
agent.page.search("td.left a").each do |offer|
Offer.create!(:name => offer.text.strip)
end
agent.get("http://odigger.com/Find-All-Affiliate-Programs?&pg=4")
agent.page.search("td.left a").each do |offer|
Offer.create!(:name => offer.text.strip)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment