J
jussi
Hi gurus
I asked this before but becose I made my self unclear I asking again. I
hope I'm able to present this time my problem.
I have an .ASP html file in a server. I need to read the file and then
replace some strings inside it. Those strins are founded from scalar
and I know the name to match in the orginal HTML file.
Here is the script so far:
------------- START ----------------
#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;
use HTML::TreeBuilder;
open(REUTERS,"> /var/www/html/FileSearch.asp");
#Get the orginal file
my $html = get("http://10.10.10.158/FileSearch.asp");
die "Couldn't get it!" unless defined $html;
#Use HTML::TreeBuilder to find the right string
my $tree = HTML::TreeBuilder->new();
$tree->parse($html);
# find elements containing: src="images/play_ico.gif"
foreach my $img ( $tree->look_down('src',
'images/play_ico.gif') ) {
next unless $img->tag eq 'img';
next unless $img->parent->tag eq 'a';
my $href = $img->parent->attr('href');
print "$href\n";
}
------------- END ---------------------
Ok. When I run this, its prints out:
javascriptopUpPlayFile('./PlayFile.asp?E:\\Reuters\\video\\110-JORDAN-AID.mpg@$$@110-JORDAN-AID',1)
javascriptopUpPlayFile('./PlayFile.asp?E:\\Reuters\\video\\109-INDIA-KASHMIRRELIEFCAMP.mpg@$$@109-INDIA-KASHMIR%CH20RELIEF%CH20CAMP',1)
These are string I want to change for playing directly from network
drive:
"file://videoserver/mpg1/"110-JORDAN-AID.mpg"
"file://videoserver/mpg1/109-INDIA-KASHMIRRELIEFCAMP.mpg"
So the BIG question is, how do I search a string and replace it ??
It shoul do like:
-------------- START -------------
#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;
use HTML::TreeBuilder;
open(REUTERS,"> /var/www/html/FileSearch.asp");
#Get the orginal file
my $html = get("http://10.10.10.158/FileSearch.asp");
die "Couldn't get it!" unless defined $html;
my $videoname = "110-JORDAN-AID.mpg";
## So we need to find string:
javascriptopUpPlayFile('./PlayFile.asp?E:\\Reuters\\video\\$videoname@$$@110-JORDAN-AID',1)
## And replace with this one:
file://videoserver/mpg1/"110-JORDAN-AID.mpg
------------ END ---------------------
Any hints would be very nice.
-Jussi
I asked this before but becose I made my self unclear I asking again. I
hope I'm able to present this time my problem.
I have an .ASP html file in a server. I need to read the file and then
replace some strings inside it. Those strins are founded from scalar
and I know the name to match in the orginal HTML file.
Here is the script so far:
------------- START ----------------
#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;
use HTML::TreeBuilder;
open(REUTERS,"> /var/www/html/FileSearch.asp");
#Get the orginal file
my $html = get("http://10.10.10.158/FileSearch.asp");
die "Couldn't get it!" unless defined $html;
#Use HTML::TreeBuilder to find the right string
my $tree = HTML::TreeBuilder->new();
$tree->parse($html);
# find elements containing: src="images/play_ico.gif"
foreach my $img ( $tree->look_down('src',
'images/play_ico.gif') ) {
next unless $img->tag eq 'img';
next unless $img->parent->tag eq 'a';
my $href = $img->parent->attr('href');
print "$href\n";
}
------------- END ---------------------
Ok. When I run this, its prints out:
javascriptopUpPlayFile('./PlayFile.asp?E:\\Reuters\\video\\110-JORDAN-AID.mpg@$$@110-JORDAN-AID',1)
javascriptopUpPlayFile('./PlayFile.asp?E:\\Reuters\\video\\109-INDIA-KASHMIRRELIEFCAMP.mpg@$$@109-INDIA-KASHMIR%CH20RELIEF%CH20CAMP',1)
These are string I want to change for playing directly from network
drive:
"file://videoserver/mpg1/"110-JORDAN-AID.mpg"
"file://videoserver/mpg1/109-INDIA-KASHMIRRELIEFCAMP.mpg"
So the BIG question is, how do I search a string and replace it ??
It shoul do like:
-------------- START -------------
#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;
use HTML::TreeBuilder;
open(REUTERS,"> /var/www/html/FileSearch.asp");
#Get the orginal file
my $html = get("http://10.10.10.158/FileSearch.asp");
die "Couldn't get it!" unless defined $html;
my $videoname = "110-JORDAN-AID.mpg";
## So we need to find string:
javascriptopUpPlayFile('./PlayFile.asp?E:\\Reuters\\video\\$videoname@$$@110-JORDAN-AID',1)
## And replace with this one:
file://videoserver/mpg1/"110-JORDAN-AID.mpg
------------ END ---------------------
Any hints would be very nice.
-Jussi