tindavid
asked on
Extract multiple value with delimiters from a string
Hi All,
I have a simple perl script that can extract the source code from a webpage like below:
#!/usr/local/bin/perl
use WWW::Mechanize;
my $page = WWW::Mechanize->new();
#$page->get("http://www.hkjc.com/english/racing/selecthorsebychar.asp?ordertype=B");
$page->get("http://www.hkjc.com/chinese/racing/selecthorsebychar.asp?ordertype=2");
my $data = $page->res()->content();
print $data;
What actually in the $data is a single string that contain some data that are useful for me:
What I need to is extract the information of
HorseNo=T108
HorseNo=T252
.......
Please send me your revised perl code for the task.
Thank you,
David
I have a simple perl script that can extract the source code from a webpage like below:
#!/usr/local/bin/perl
use WWW::Mechanize;
my $page = WWW::Mechanize->new();
#$page->get("http://www.hkjc.com/english/racing/selecthorsebychar.asp?ordertype=B");
$page->get("http://www.hkjc.com/chinese/racing/selecthorsebychar.asp?ordertype=2");
my $data = $page->res()->content();
print $data;
What actually in the $data is a single string that contain some data that are useful for me:
What I need to is extract the information of
HorseNo=T108
HorseNo=T252
.......
Please send me your revised perl code for the task.
Thank you,
David
As arnold said, you don't provide us with enough $data to construct a good regex (or other means of extraction).
ASKER
I don't understand, you mean the data from get() is not good enough for program to extract data after a pattern of "
horse.asp?HorseNo", all I need is the T322, T323, T340 .....
If you cut and paste the perl code and run it you should see the output , the value in the data is come from the get("http://www.hkjc.com/chinese/racing/selecthorsebychar.asp?ordertype=2");
what I want is to continue the code : print $data
to search $data to extract all information from the $data
.......class=table_Text><a href="horse.asp?HorseNo=T3 22" ......
.......class=table_Text><a href="horse.asp?HorseNo=T3 33" ......
.......class=table_Text><a href="horse.asp?HorseNo=T3 40"....... .
horse.asp?HorseNo", all I need is the T322, T323, T340 .....
If you cut and paste the perl code and run it you should see the output , the value in the data is come from the get("http://www.hkjc.com/chinese/racing/selecthorsebychar.asp?ordertype=2");
what I want is to continue the code : print $data
to search $data to extract all information from the $data
.......class=table_Text><a
.......class=table_Text><a
.......class=table_Text><a
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
To see whether there is a separator, is the sata as it is represented one entry per line?