HTML parser using Hpricot

C

Cincin Robert

Hello folks,

I am a newbie to RoR and writing an HTML parser using Hpricot. I can
parse a html file with:
(1) doc = open( "MyFileToParse.html" ) { |f| Hpricot(f) }
(2) elements = (doc.search("/html/body/table/tr/td/table/tr/td/font") )
(3) puts (elements[13]).inner_html

to get the following output:

Giaever G, et al (2002). Functional profiling of the Saccharomyces c
erevisiae genome. Nature, 418:387-91. [<a
href="http://www.ncbi.nlm.nih.gov/entr
ez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=12140549&dopt=Abstract"
target="_
blank">PubMed</a>]

How can I proceed to get the following results (3) and (4) respectively?
(3) Giaever G, et al (2002). Functional profiling of the Saccharomyces c
erevisiae genome. Nature, 418:387-91.

(4) http://www.ncbi.nlm.nih.gov/pubmed/12140549?dopt=Abstract

NOTE: to get (4) I need to take two more steps: (5) replace "&" with "?"
(6) replace "PubMed" with "pubmed" (this might be trivial, but how?) in
the process of parsing in addition to "normal" HTML parsing.

Thanks a lot in advance.
Robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top