[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

hpricot search help

Junkone

3/16/2008 5:26:00 PM

hello
I am trying to grab the table that has a html comment in it. for eg

<TABLE cellSpacing=1 width="80%" align=center border=0><!--
startingtable -->

how can i do using search functionality in hpricot.

appreciate any help
25 Answers

Phlip

3/16/2008 5:59:00 PM

0

Junkone wrote:

> <TABLE cellSpacing=1 width="80%" align=center border=0><!--
> startingtable -->

You simply cannot identify the table by an ID, or containership?

> how can i do using search functionality in hpricot.

Here's a little experiment showing how to do that:

html = %(<html><body>
<div><!-- yo --></div>
</body></html>)

html = Hpricot(html)
p (html/:body/:div).innerHTML

That spews "<!-- yo -->".

However, I wouldn't know how to bottle that up into a cute query. The ugly
way is to loop through all the 'div's that statement returns, checking the
innerHTML of each one for a '<--' mark.

I would prefer to query HTML with XPath, but Hpricot cannot do complex
XPaths. Other libraries could, if your HTML were well-formed. If you can't
well-form it, I would pass it thru tidy -asxhtml, then query it with REXML
or LIBxml.

--
Phlip


Todd Benson

3/16/2008 11:04:00 PM

0

On Sun, Mar 16, 2008 at 12:30 PM, Junkone <junkone1@gmail.com> wrote:
> hello
> I am trying to grab the table that has a html comment in it. for eg
>
> <TABLE cellSpacing=1 width="80%" align=center border=0><!--
> startingtable -->
>
> how can i do using search functionality in hpricot.
>
> appreciate any help
>
>

There's probably a better way, but without looking at the docs I would
probably find my table and then maybe #inner_html followed with a
regexp.

For example...

require "hpricot"
str = <TABLE cellspacing=1 width= 80% align=center border=0><!--
startingtable -->
doc = Hpricot(str)
p doc.search("table").inner_html

=>"<!-- startingtable -->\n"

It's interesting to note that hpricot picked it out even though that
string is really malformed html.

Todd

daniel hoey

3/17/2008 3:37:00 AM

0

On Mar 17, 10:03 am, Todd Benson <caduce...@gmail.com> wrote:
> On Sun, Mar 16, 2008 at 12:30 PM, Junkone <junko...@gmail.com> wrote:
> > hello
> > I am trying to grab the table that has a html comment in it. for eg
>
> > <TABLE cellSpacing=1 width="80%" align=center border=0><!--
> > startingtable -->
>
> > how can i do using search functionality in hpricot.
>
> > appreciate any help
>
> There's probably a better way, but without looking at the docs I would
> probably find my table and then maybe #inner_html followed with a
> regexp.
>
> For example...
>
> require "hpricot"
> str = <TABLE cellspacing=1 width= 80% align=center border=0><!--
> startingtable -->
> doc = Hpricot(str)
> p doc.search("table").inner_html
>
> =>"<!-- startingtable -->\n"
>
> It's interesting to note that hpricot picked it out even though that
> string is really malformed html.
>
> Todd

I think that this will do it:

h = Hpricot('<table><!-- startingtable --></table><div><!-- some div --
></div>')
table = (h/'table > comment()')[0].parent

Frank Berger

2/11/2014 7:54:00 PM

0

On 2/11/2014 1:07 PM, Gerard wrote:
>
>
> "Frank Berger" wrote in message
> news:ko6dnX-M_9Hh0GfPnZ2dnUVZ_iydnZ2d@supernews.com...
>
> On 2/11/2014 10:08 AM, RiRiIII wrote:
>> Through the special services of cdjapan, I just received the exclusive
>> DG/Tower 4-cd box set that includes Lazar Berman's recordings of
>> russian solo piano works originally issued on 4 Lps:
>>
>> - Mussorgsky Pictures
>> - Prokofiev: Romeo & Juliet, Sonatas 2 and 8
>> - Shostakovich: Preludes op. 34 (sel.)
>> - Rachmaninov: Six Moments Musicaux op. 16, Six Preludes and Corelli
>> Variations
>>
>> In the same package: Enrico Mainardi DG recordings (lovely set - a lot
>> space lost - a former Archiv 45 rpm with one (1) Vivaldi cto on one
>> CD... Bach cello suites in 4 Cds - original sleeves reproduced), and
>> the Mengelberg-Tchaikovsky Telefunken recs.
>>
>> For anybody interested, the whole procedure (cdjapan fee and EMS
>> shipping) adds 50% to the listed price of the items.
>>
>> AR
>>
>
> Is this the Berman set?
>
> http://tinyurl.c...
>
> It shows as 3 cds, not 4
>
> =================
>
> So does the subject line of this thread.
>
>
>
>

And the text says 4. I just wanted to clear it up.

Bob Lombard

2/11/2014 8:31:00 PM

0

On 2/11/2014 2:53 PM, Frank Berger wrote:
> On 2/11/2014 1:07 PM, Gerard wrote:
>>
>>
>> "Frank Berger" wrote in message
>> news:ko6dnX-M_9Hh0GfPnZ2dnUVZ_iydnZ2d@supernews.com...
>>
>> On 2/11/2014 10:08 AM, RiRiIII wrote:
>>> Through the special services of cdjapan, I just received the exclusive
>>> DG/Tower 4-cd box set that includes Lazar Berman's recordings of
>>> russian solo piano works originally issued on 4 Lps:
>>>
>>> - Mussorgsky Pictures
>>> - Prokofiev: Romeo & Juliet, Sonatas 2 and 8
>>> - Shostakovich: Preludes op. 34 (sel.)
>>> - Rachmaninov: Six Moments Musicaux op. 16, Six Preludes and Corelli
>>> Variations
>>>
>>> In the same package: Enrico Mainardi DG recordings (lovely set - a lot
>>> space lost - a former Archiv 45 rpm with one (1) Vivaldi cto on one
>>> CD... Bach cello suites in 4 Cds - original sleeves reproduced), and
>>> the Mengelberg-Tchaikovsky Telefunken recs.
>>>
>>> For anybody interested, the whole procedure (cdjapan fee and EMS
>>> shipping) adds 50% to the listed price of the items.
>>>
>>> AR
>>>
>>
>> Is this the Berman set?
>>
>> http://tinyurl.c...
>>
>> It shows as 3 cds, not 4
>>
>> =================
>>
>> So does the subject line of this thread.
>>
>>
>>
>>
>
> And the text says 4. I just wanted to clear it up.

You were hoping to explain something to Gerard? Does this mean he has
turned over a new leaf?

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www...

td

2/11/2014 8:55:00 PM

0

On Tuesday, February 11, 2014 3:31:14 PM UTC-5, Bob Lombard wrote:
> On 2/11/2014 2:53 PM, Frank Berger wrote:
>
> > On 2/11/2014 1:07 PM, Gerard wrote:
>
> >>
>
> >>
>
> >> "Frank Berger" wrote in message
>
> >> news:ko6dnX-M_9Hh0GfPnZ2dnUVZ_iydnZ2d@supernews.com...
>
> >>
>
> >> On 2/11/2014 10:08 AM, RiRiIII wrote:
>
> >>> Through the special services of cdjapan, I just received the exclusive
>
> >>> DG/Tower 4-cd box set that includes Lazar Berman's recordings of
>
> >>> russian solo piano works originally issued on 4 Lps:
>
> >>>
>
> >>> - Mussorgsky Pictures
>
> >>> - Prokofiev: Romeo & Juliet, Sonatas 2 and 8
>
> >>> - Shostakovich: Preludes op. 34 (sel.)
>
> >>> - Rachmaninov: Six Moments Musicaux op. 16, Six Preludes and Corelli
>
> >>> Variations
>
> >>>
>
> >>> In the same package: Enrico Mainardi DG recordings (lovely set - a lot
>
> >>> space lost - a former Archiv 45 rpm with one (1) Vivaldi cto on one
>
> >>> CD... Bach cello suites in 4 Cds - original sleeves reproduced), and
>
> >>> the Mengelberg-Tchaikovsky Telefunken recs.
>
> >>>
>
> >>> For anybody interested, the whole procedure (cdjapan fee and EMS
>
> >>> shipping) adds 50% to the listed price of the items.
>
> >>>
>
> >>> AR
>
> >>>
>
> >>
>
> >> Is this the Berman set?
>
> >>
>
> >> http://tinyurl.c...
>
> >>
>
> >> It shows as 3 cds, not 4
>
> >>
>
> >> =================
>
> >>
>
> >> So does the subject line of this thread.
>
> >>
>
> >>
>
> >>
>
> >>
>
> >
>
> > And the text says 4. I just wanted to clear it up.
>
>
>
> You were hoping to explain something to Gerard? Does this mean he has
>
> turned over a new leaf?

Sarcasm is not your usual method, Bob. Don't tell me that you have turned over a new leaf.

TD

John Wiser

2/11/2014 9:55:00 PM

0

"td" <tomdedeacon@mac.com> wrote in message
news:2458577d-4015-4a90-ad1d-e23d91db792d@googlegroups.com...
> On Tuesday, February 11, 2014 3:31:14 PM UTC-5, Bob Lombard wrote:
>> On 2/11/2014 2:53 PM, Frank Berger wrote:
>>
>> > On 2/11/2014 1:07 PM, Gerard wrote:
>>
>> >>
>>
>> >>
>>
>> >> "Frank Berger" wrote in message
>>
>> >> news:ko6dnX-M_9Hh0GfPnZ2dnUVZ_iydnZ2d@supernews.com...
>>
>> >>
>>
>> >> On 2/11/2014 10:08 AM, RiRiIII wrote:
>>
>> >>> Through the special services of cdjapan, I just received the exclusive
>>
>> >>> DG/Tower 4-cd box set that includes Lazar Berman's recordings of
>>
>> >>> russian solo piano works originally issued on 4 Lps:
>>
>> >>>
>>
>> >>> - Mussorgsky Pictures
>>
>> >>> - Prokofiev: Romeo & Juliet, Sonatas 2 and 8
>>
>> >>> - Shostakovich: Preludes op. 34 (sel.)
>>
>> >>> - Rachmaninov: Six Moments Musicaux op. 16, Six Preludes and Corelli
>>
>> >>> Variations
>>
>> >>>
>>
>> >>> In the same package: Enrico Mainardi DG recordings (lovely set - a lot
>>
>> >>> space lost - a former Archiv 45 rpm with one (1) Vivaldi cto on one
>>
>> >>> CD... Bach cello suites in 4 Cds - original sleeves reproduced), and
>>
>> >>> the Mengelberg-Tchaikovsky Telefunken recs.
>>
>> >>>
>>
>> >>> For anybody interested, the whole procedure (cdjapan fee and EMS
>>
>> >>> shipping) adds 50% to the listed price of the items.
>>
>> >>>
>>
>> >>> AR
>>
>> >>>
>>
>> >>
>>
>> >> Is this the Berman set?
>>
>> >>
>>
>> >> http://tinyurl.c...
>>
>> >>
>>
>> >> It shows as 3 cds, not 4
>>
>> >>
>>
>> >> =================
>>
>> >>
>>
>> >> So does the subject line of this thread.
>>
>> >>
>>
>> >>
>>
>> >>
>>
>> >>
>>
>> >
>>
>> > And the text says 4. I just wanted to clear it up.
>>
>>
>>
>> You were hoping to explain something to Gerard? Does this mean he has
>>
>> turned over a new leaf?
>
> Sarcasm is not your usual method, Bob. Don't tell me that you have turned over a new leaf.
>

I think that Bob is boggled by the spectacle
of a cranberry trying to explain something
to another cranberry.

jdw

Frank Berger

2/11/2014 10:05:00 PM

0

On 2/11/2014 3:31 PM, Bob Lombard wrote:
> On 2/11/2014 2:53 PM, Frank Berger wrote:
>> On 2/11/2014 1:07 PM, Gerard wrote:
>>>
>>>
>>> "Frank Berger" wrote in message
>>> news:ko6dnX-M_9Hh0GfPnZ2dnUVZ_iydnZ2d@supernews.com...
>>>
>>> On 2/11/2014 10:08 AM, RiRiIII wrote:
>>>> Through the special services of cdjapan, I just received the exclusive
>>>> DG/Tower 4-cd box set that includes Lazar Berman's recordings of
>>>> russian solo piano works originally issued on 4 Lps:
>>>>
>>>> - Mussorgsky Pictures
>>>> - Prokofiev: Romeo & Juliet, Sonatas 2 and 8
>>>> - Shostakovich: Preludes op. 34 (sel.)
>>>> - Rachmaninov: Six Moments Musicaux op. 16, Six Preludes and Corelli
>>>> Variations
>>>>
>>>> In the same package: Enrico Mainardi DG recordings (lovely set - a lot
>>>> space lost - a former Archiv 45 rpm with one (1) Vivaldi cto on one
>>>> CD... Bach cello suites in 4 Cds - original sleeves reproduced), and
>>>> the Mengelberg-Tchaikovsky Telefunken recs.
>>>>
>>>> For anybody interested, the whole procedure (cdjapan fee and EMS
>>>> shipping) adds 50% to the listed price of the items.
>>>>
>>>> AR
>>>>
>>>
>>> Is this the Berman set?
>>>
>>> http://tinyurl.c...
>>>
>>> It shows as 3 cds, not 4
>>>
>>> =================
>>>
>>> So does the subject line of this thread.
>>>
>>>
>>>
>>>
>>
>> And the text says 4. I just wanted to clear it up.
>
> You were hoping to explain something to Gerard? Does this mean he has
> turned over a new leaf?
>
> ---
> This email is free from viruses and malware because avast! Antivirus
> protection is active.
> http://www...
>

No. When Gerard sees my name on a post, he foams at the mouth hoping to
find something I've said to find fault with. Doesn't bother me.

Bob Lombard

2/11/2014 10:12:00 PM

0

On 2/11/2014 4:55 PM, John Wiser wrote:
>
> I think that Bob is boggled by the spectacle
> of a cranberry trying to explain something
> to another cranberry.
>
> jdw

I don't abstain from gentle sarcasm, Tom, but in this instance my fairly
prolonged absence from the ng is at fault. I have always believed that
Gerard actively resists all subtleties and nuances. Our Texas banker
friend has always been willing to explain himself, even though he is
usually unsuccessful. I was surprised even so that he would make a try
at Gerard.

bl

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www...

Frank Berger

2/12/2014 12:45:00 AM

0

On 2/11/2014 5:11 PM, Bob Lombard wrote:
> On 2/11/2014 4:55 PM, John Wiser wrote:
>>
>> I think that Bob is boggled by the spectacle
>> of a cranberry trying to explain something
>> to another cranberry.
>>
>> jdw
>
> I don't abstain from gentle sarcasm, Tom, but in this instance my fairly
> prolonged absence from the ng is at fault. I have always believed that
> Gerard actively resists all subtleties and nuances. Our Texas banker
> friend

I prefer to be referred as "our Baltimore retiree friend." Or if you
prefer, "our idle Baltimoron." And I was never a banker.


has always been willing to explain himself, even though he is
> usually unsuccessful.

By which you mean I don't win over people who don't already share my
point of view? Does anyone here? No. That would make me as successful
as anyone else.

I was surprised even so that he would make a try
> at Gerard.
>

The fact that I technically replied to Gerard doesn't really mean he was
the target of my explanation.


> bl
>
> ---
> This email is free from viruses and malware because avast! Antivirus
> protection is active.
> http://www...
>