Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by Cody Fendant (Hermit)
on Apr 16, 2013 at 11:03 UTC ( [id://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?

Replies are listed 'Best First'.
Re: How to get the fragment of a URI from WWW::Mechanize ?
by Corion (Patriarch) 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 (Archbishop) 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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-03-19 11:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found