Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Mon-Ouie/3395604 to your computer and use it in GitHub Desktop.
Save Mon-Ouie/3395604 to your computer and use it in GitHub Desktop.
the database insert doesnt loop but the puts do.
def mura_collect # naming conventions
# begin <- begin is implied in a function
#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@addr.com",
"Referer" => "http://www.google.com") { |f|
@mura_response = f.read # do you need an ivar here?
}
doc = Hpricot(@mura_response)
# Get Dataz & store into DB
# Walk the days of the week that have specials
[['Sunday', MuraS], ['Monday', MuraM]].each do |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}'")
end
# rescue Exception => e <- that's just asking for pain
# print e, "\n"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment