extract from html

L

Lydia Shawn

hi,
how can i extract the number between text1 and text2 in input.html
only the first time it occurs ignoring the rest?
preferably input.html would be a URL that stops downloading once a
match has occured, that would save a lot of bandwidth..
i guess html::parser would provide an option to work with a file while
it's downloading (?)

example
----

input.html:

bla..
text1 555 text2
bla
bla
text1 6000 text2
bla
EOF


output.txt
555


thanks for your help,
peter
 
M

Michael Korte

Lydia Shawn said:
hi,
how can i extract the number between text1 and text2 in input.html
only the first time it occurs ignoring the rest?

This problem I would solve by using a Hash. You can just put a unique key
into it, while finding the same term
it will be overwritten, or you can ask the hash if the term already exist

# $term is taken from your text - inbeetween text1 / text2
if( exists $myHash{$term})
{
# ignore
}else
{
$myHash{$term} = $value;
}

The Rest of your question : I don´t know ... sorry
thanks for your help,
peter

no prob...but what is your real name ?
"Lydia Shawn" or Peter :)

HTH
greets Michael
 
B

Brian Helterline

Lydia Shawn said:
hi,
how can i extract the number between text1 and text2 in input.html
only the first time it occurs ignoring the rest?
preferably input.html would be a URL that stops downloading once a
match has occured, that would save a lot of bandwidth..
i guess html::parser would provide an option to work with a file while
it's downloading (?)

Take a look at the lwp-download script (in your perl bin directory)
as an example of a program that incrementally downloads a URL.
You can then search the contents for your text1 and text2 and stop if found.

The script uses LWP::UserAgent to do the download.
 

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

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
KetoBurn
Top