Skip to content

Instantly share code, notes, and snippets.

@jimmybaker
Forked from anonymous/gist:467111
Created July 7, 2010 19:13
Show Gist options
  • Save jimmybaker/467123 to your computer and use it in GitHub Desktop.
Save jimmybaker/467123 to your computer and use it in GitHub Desktop.
desc "Fetch affiliate offers"
task :getoffers => :environment do
require 'nokogiri'
require 'open-uri'
Offer.find(:all).each do |offer|
url = "http://www.findaffiliateoffers.com/index.php?function=search&search="
doc = Nokogiri::HTML(open(url))
payout = doc.at_css(".l4").text[/[0-9\.]+/]
offer.update_attribute(:payout, payout)
end
I = Offer.new
I.each do |offers|
url = "http://www.findaffiliateoffers.com/index.php?function=search&search="
doc = Nokogiri::HTML(open(url))
name = doc.at_css(".l3").text
offer.update_attribute(:name, name)
payout = doc.at_css(".l4").text[/[0-9\.]+/]
offer.update_attribute(:payout, payout)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment