use LWP::UserAgent; use URI; my $response = LWP::UserAgent->new->get('http://search.cpan.org/'); $html = $response->content; $base = $response->base; # RegEx converts all links in $html to absolute URLs $html =~ s/<(.*?)(href|src|action|background)\s*=\s*("|'?)(.*?)\3((\s+ +.*?)*)>/"<".$1.$2."=\"".URI->new_abs($4,$base)->as_string."\"".$5.">" +/eigs; print $html;
In reply to Convert Relative to Absolute URLs on-the-fly by nikhil.patil
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |