Skip to content

Instantly share code, notes, and snippets.

Created August 19, 2012 15:45
Show Gist options
  • Save anonymous/3395527 to your computer and use it in GitHub Desktop.
Save anonymous/3395527 to your computer and use it in GitHub Desktop.
the database insert doesnt loop but the puts do.
#Define Functions
def Mura_Collect()
begin
#define function Variables
query_name = "Mura"
con = Mysql.new(DB_Host, DB_User, DB_Pass, DB_Table)
open(@Mura_url, "User-Agent" => "Firefox",
"From" => "[email protected]",
"Referer" => "http://www.google.com") { |f|
@Mura_response = f.read
}
doc = Hpricot(@Mura_response)
#Get Dataz & store into DB
#Walk the days of the week that have specials
[ ['Sunday', MuraS], ['Monday', MuraM] ].each{|query_day, venue_day|
puts "Collecting data for #{query_name} (#{query_day}) & updating the database"
sanitized_data = (doc/venue_day).inner_html.gsub!(RemSpace, " ").gsub!(RemTags," ")
puts query_day
con.query("UPDATE specials SET data='#{sanitized_data}' WHERE name='#{query_name}' AND day='#{query_day}'")
}
rescue Exception => e
print e, "\n"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment