Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^4: Mojo::URL returns incorrect absolute path

by Anonymous Monk
on May 17, 2013 at 04:21 UTC ( #1033940=note: print w/replies, xml ) Need Help??

in reply to Re^3: Mojo::URL returns incorrect absolute path
in thread Mojo::URL returns incorrect absolute path

#!/usr/bin/perl -- use strict; use warnings; use Mojo::DOM; use Mojo::URL; my $dom = Mojo::DOM->new( '<div> <base href=""> <a href="/bar/">/bar/</a> <a href="baz/biz">baz/biz</a> <a href="#burp">#burp bug </a> </div>' ); #~ $dom->at('base[href]')->each( ## grr $dom->find('base[href]')->each( sub { my( $base , $count ) = @_; $base = $base->attrs('href'); if(length $base ){ $dom->find('a[href]')->each( sub { my ( $link, $count ) = @_; my $href = $link->attrs('href'); $href = Mojo::URL->new($href)->base( Mojo::URL->new($base) ) +->to_abs; #~ $href and $link->attrs(href => $href ); $href and $link->attrs( href => "$href" ); return; }, ); } }, ); for my $l ( $dom->find('a[href]')->each ) { print $l->attrs('href'), "\n"; } __END__

Replies are listed 'Best First'.
Re^5: Mojo::URL returns incorrect absolute path
by mr_p (Scribe) on May 17, 2013 at 14:36 UTC

    I am sorry that I did not mention that I ran Data::Dumper on it.

    I did run Data::Dumper on it. It had two parts for 'page' 'page'.

    This problem does not happen all the time. it only happens sometimes.

      :)really? why not share the dumpered data, instead of an external url that can change?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1033940]
[Corion]: marto: Ow, I hope that gets better soonish! But I feel some $work-timecrunch looming at my $work as well
[Corion]: marto: Ah, so you can multiplex work and PM time ;-D
[Corion]: The upside to this is that I've reduced my $work (well, $paid) time to 80%, so I'll be at $work only four days/week, which will hopefully make the crunch less crunchy on me ;)
[marto]: yeah, so that stays as before. But before the boys were born I'd be on quite often at night (GMT) also
[marto]: I had the option during our TUPE transfer to buy 5 more days holiday. They were shocked when I did :P

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2017-06-29 08:24 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (655 votes). Check out past polls.