Created
August 19, 2012 15:45
-
-
Save anonymous/3395527 to your computer and use it in GitHub Desktop.
the database insert doesnt loop but the puts do.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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