SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Hpricot

  1. #1
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hpricot

    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:
    Code:
    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

    htt
    p:
    //p
    aste
    bi
    n
    .c
    om
    /me
    31
    f6
    af

    replace enters, so silly.

  2. #2
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ????? anyone?

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2008
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's probably because people can't be bothered to correct your link. Typing pastebin . com / me31f6af might've been better.

    As it is, Hpricot is incredibly easy to use, and looking through the HTML code you should have very little trouble pulling in the info you need. Everything seems to be class'd up, which makes it super simple.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •