Skip to content

Instantly share code, notes, and snippets.

@robyurkowski
Forked from anonymous/gist:469510
Created July 9, 2010 16:46
Show Gist options
  • Save robyurkowski/469697 to your computer and use it in GitHub Desktop.
Save robyurkowski/469697 to your computer and use it in GitHub Desktop.
desc "Fetch product prices"
task :updatepayouts => :environment do
require 'mechanize'
agent = WWW::Mechanize.new
Offer.find_all_by_payout(nil).each do |offer|
escaped_offer_name = CGI.escape("\"#{offer.name}\"")
agent.get("http://odigger.com/?&q=#{escaped_offer_name}&network_id=")
agent.page.search(".payout").each do |offer2|
offer.update_attribute(:payout, offer2.text.strip)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment