Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
XP is just a number
 
PerlMonks  

How to get the fragment of a URI from WWW::Mechanize ?

by Cody Fendant (Pilgrim)
on Apr 16, 2013 at 11:03 UTC ( #1028874=perlquestion: print w/ replies, xml ) Need Help??
Cody Fendant has asked for the wisdom of the Perl Monks concerning the following question:

This is probably pretty simple, but I can't figure it out.

Say a website redirects me to example.com#foobar -- how do I get the #foobar part of the URI from the $mech object?

Comment on How to get the fragment of a URI from WWW::Mechanize ?
Re: How to get the fragment of a URI from WWW::Mechanize ?
by Corion (Pope) on Apr 16, 2013 at 11:28 UTC

    See URI. That part of the URI is named the "fragment".

      $ perl -MURI -e " print URI->new( shift )->fragment " http://a/#frag frag
Re: How to get the fragment of a URI from WWW::Mechanize ?
by Your Mother (Canon) on Apr 17, 2013 at 02:31 UTC

    Iíll go one more step. :P

    perl -MWWW::Mechanize -le '$m=WWW::Mechanize->new; $m->get("http://per +lmonks.org/#wut"); print $m->uri->fragment' wut
      example.com is official url for examples :)

        Next you'll tell me wut is actually spelled what and that the Gods will take me to small claims court to make me pay for this egregious waste of perlmonks bandwidth. You guys and your things and your stuff.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1028874]
Approved by choroba
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2014-04-20 04:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls