Questions tagged [hpricot]

Hpricot is a Ruby library intended for parsing HTML. Until the release of Nokogiri, a competing HTML and css parser, Hpricot was the defacto HTML parser for the ruby community.

Hpricot is a Ruby library intended for parsing HTML. Until the release of Nokogiri, a competing HTML and css parser, Hpricot was the defacto HTML parser for the ruby community.

163 questions
0
votes
3 answers

Searching Hpricot with Regex

I'm trying to use Hpricot to get the value within a span with a class name I don't know. I know that it follows the pattern "foo_[several digits]_bar". Right now, I'm getting the entire containing element as a string and using a regex to parse the…
AaronM
  • 693
  • 5
  • 18
0
votes
3 answers

XPath and Hpricot -- works on some machines, not others?

The following hpricot code successfully extracts the STPeriods in the XML on two of my machines (Vista and an Ubuntu server) but fails on another Ubuntu laptop. All machines have Hpricot v0.82 Any ideas? Totally stumped. Hpricot code: …
ideasasylum
  • 2,130
  • 1
  • 17
  • 21
0
votes
1 answer

Loading an hpricot element with a chunk of html

is there a way to load a chunk of html into an Hpricot::Doc object? I am trying to parse various chunks of html within custom tags from a page. so if I have: here is some stuff
cgr
  • 1,093
  • 1
  • 8
  • 14
0
votes
1 answer

How do I use Hpricot to search the inner_text of all elements?

I would like to use Hpricot to scan the inner_text of all elements, and know what element is currently being scanned. However, each approach I have taken leads to a recursion. Is there a built-in function to do this with Hpricot (or Nokogiri)? The…
Jackson Henley
  • 1,531
  • 2
  • 15
  • 27
0
votes
2 answers

Update a single XML entity using Hpricot in Ruby?

I am going to be using Hpricot to process an XML file. I want to randomly display some quotes from the file, and then I want to keep track of how often each quote has been displayed. Is it possible for me to update a single item within the XML file…
James P. Wright
  • 8,991
  • 23
  • 79
  • 142
0
votes
1 answer

What is the best way to match id's against a regular expression in Hpricot?

Using apricot, it is pretty easy to see how I can extract all elements with a given id or class using a CSS Selector. Is it possible to extract elements from a document based on whether some attribute of those elements matches against some regular…
Paul Wicks
  • 62,960
  • 55
  • 119
  • 146
0
votes
1 answer

hpricot problem

I am trying to use hpricot in a controller. I would like to pass this value to a html.erb page so I can display it on the screen So I wrote this: session[:allcars] = (doc/"td.car_title/text()") but this gives an error when I tried this: puts…
Lilz
  • 4,013
  • 13
  • 61
  • 95
0
votes
1 answer

hpricot in netbeans

I am trying to use hpricot in JRuby. My problem is the following. If I have this code: #!ruby require 'hpricot' require 'open-uri' # load the RedHanded home page doc = Hpricot(open("http://redhanded.hobix.com/index.html")) where do I put…
Lilz
  • 4,013
  • 13
  • 61
  • 95
0
votes
3 answers

Scraping hidden HTML (when visible = false) using Hpricot (Ruby on Rails)

I've come across an issue which unfortunately I can't seem to surpass, I'm also just a newborn to Ruby on rails unfortunately hence the number of questions I am attempting to scrape a webpage such as the…
Erika
  • 2,045
  • 7
  • 25
  • 31
0
votes
2 answers

Html / Script Scraping Google Map using Hpricot (Ruby On Rails)

I am having a problem Scraping Code i require to extract information for a Web MashUp i'm creating. Basically, I am trying to Scrape Code from: http://yellowpages.com.mt/Meranti-Ltd-In-Malta-Gozo;/Hair-Accessories;Hijjhkikke=Hiojhhfokje.aspx This…
Erika
  • 2,045
  • 7
  • 25
  • 31
0
votes
1 answer

HTML Scraping with Hpricot (Using Ruby on Rails)

I have read a large deal of tutorials to help out and under Hpricot, the problem that i am finding out it is not scraping all the Html so to speak. I'll elaborate: The website i am attempting to scrape html off is…
Erika
  • 2,045
  • 7
  • 25
  • 31
0
votes
2 answers

Checking emptiness of an element in hpricot

Let's say this is the location element: <.location>blah...<./location> It can be empty like this: <.location/> Is there a way to detect the backslash in the empty element in order to not return it?
Ben
  • 5,030
  • 6
  • 53
  • 94
0
votes
1 answer

Get the type of an element in Hpricot

I want to go through the children of an element and filter only the ones that are text or span, something like: element.children.select {|child| child.class == String || child.element_type == 'span' } but I can't find a way to test which type a…
agentofuser
  • 8,987
  • 11
  • 54
  • 85
0
votes
2 answers

Parse XML with hpricot, get attributes

My xml: http://www.google.ru/ig/api?weather=Chelyabinsk How to get city data for example? Not inner_html, just attributes like city data, postal…
0
votes
0 answers

Parsing website with Hpricot

I'm trying to parse images from reddit using Ruby and the Hpricot gem. Using Chrome I got the XPath to the div holding the link to the image then I use doc.search to find it but the results come up…
user1310856
  • 335
  • 1
  • 3
  • 7
1 2 3
10
11
one two