Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: url get with string

by haukex (Archbishop)
on Mar 23, 2017 at 08:49 UTC ( [id://1185574]=note: print w/replies, xml ) Need Help??


in reply to url get with string

If $name is just a simple string like you showed, with no special characters, then huck has given you the answer in regards to interpolation in '$name' vs. "$name".

However, if you've got any special characters in that string, they need to be escaped properly. Here's one way with URI:

use URI; my $name = 'xyz&foo=bar'; my $uri = URI->new('https://www.google.com/'); $uri->query_form( name => $name, foo => 'quz', ); print "$uri\n"; __END__ https://www.google.com/?name=xyz%26foo%3Dbar&foo=quz

Replies are listed 'Best First'.
Re^2: url get with string
by bigup401 (Pilgrim) on Mar 23, 2017 at 10:36 UTC

    haukex am using LWP::UserAgent, guys non of idea has worked,most guys dont believe that some url dont accept using string in url they only allow normal form. so u just have to bypass or force it. any better idea i appreciate

        here is a working code, anyone can try

        my $req = HTTP::Request->new(GET => 'https://www.google.com/finance/co +nverter?a=3&from=USD&to=EUR'); $req->content_type('application/json'); my $re = $ua->request($req); $re->content =~ m|<span class=bld>(.+?)</span>|i and $span = $1; $ct = substr($1, 0, -6); print $ct; prints 2.77 according to the currency usd to euro

        but when you try to put amount from string $m = "3";

        https://www.google.com/finance/converter?a=$m&from=USD&to=EUR

        doesn;t work correctly

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1185574]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2024-04-24 17:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found