in reply to Re: Extract CSS + JS + Image URLs from a HTML page?
in thread Extract CSS + JS + Image URLs from a HTML page?
..with this being the bit in question:sub get_js { my $tmp = shift ; my $self ; my $url ; my $html ; my @result_arr ; my $user_agent = "Html_Miner/0.01" ; my $timeout = 60 ; my $domain ; ## First extract all required information. if( UNIVERSAL::isa( $tmp, 'HTML::Miner' ) ) { $self = $tmp ; $url = $self->{ CURRENT_URL } ; $html = $self->{ CURRENT_URL_HTML } ; $domain = $self->{ _BASE_DOMAIN } ; } else { $url = $tmp ; ## Check for validity of url! my ( $tmp, $protocol, $domain, $uri ) = _convert_to_valid_url( $url ) ; $url = $tmp ; my @params = @_ ; my $html_has_been_passed = @params ; if( $html_has_been_passed ) { $html = shift ; } else { ## Need to retrieve html eval { require LWP::UserAgent ; require HTTP::Request ; }; croak( "LWP::UserAgent and HTTP::Request are required if the u +rl is to be fetched!" ) if( $@ ); $html = _get_url_html( $url, $user_agent, $timeout ) ; } ## HTML Not passed } ## Not called on Object. while( $html =~ m/\<script .*? src=\"(.+?)\Q.js"><\/script>\E/gis +){ my $url = $1; if ($url !~ /^https?:\/\//) { $url = HTML::Miner::get_absolute_url($url); } push( @result_arr, "$url.js" ); } return \@result_arr; }
..but I keep getting this error:if ($url !~ /^https?:\/\//) { $url = HTML::Miner::get_absolute_url($url); }
A fatal error has occured: URL - http:///dev/static/utils/ - Malformed! Sorry I tried to fix +it but could not! at /var/home/linkssql/ultradev.com/cgi-bin/dev/admin/Plugins/CDN. +pm line 59 Please enable debugging in setup for more details.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Extract CSS + JS + Image URLs from a HTML page?
by tmharish (Friar) on Jan 28, 2011 at 19:15 UTC | |
by ultranerds (Hermit) on Jan 31, 2011 at 16:51 UTC |