PDA

View Full Version : Hpricot


charliekirk
June 25th, 2008, 11:43 AM
Hi there, this is my code so far below this. I have got to do several things with the document below my code, I need the rating saves eg 4.0, the description the review links, the tags, popularity index, the activities, the address, the email/website, the telephone number.

And thats it: code and doc:
require 'rubygems'
require 'mysql'
require 'hpricot'
require 'open-uri'
require 'htmlentities'

mysql_user = 'x'
mysql_pass = 'x'
mysql_db = 'x'
mysql_host = 'x'


# connect to mysql or die tryin'
begin
@db = Mysql.real_connect(mysql_host, mysql_user, mysql_pass, mysql_db)
rescue MysqlError => e
puts "Error code: #{e.errno}"
puts "Error message: #{e.error}"
exit
end


sql = "SELECT * FROM pages"

result = @db.query(sql)
if ( !result.num_rows.zero? )
i = 1
result.each_hash do |row|
# load the cached html into hpricot
doc = Hpricot(row['theText'])
end
lol - on pastebin

http://pastebin.com/me31f6af