Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Retrieving Data from URL

by arunhorne (Pilgrim)
on May 13, 2002 at 14:50 UTC ( [id://166198]=perlquestion: print w/replies, xml ) Need Help??

arunhorne has asked for the wisdom of the Perl Monks concerning the following question:

Monks,

I have a URL http://ca.expasy.org/cgi-bin/get-sprot-fasta?Q9PKH8 that results in text/plain output. I want to store this to a file. How can I go about doing this using Perl... the URL will be generated many times with different parameters hence need for automation.

Thanks, Arun

Replies are listed 'Best First'.
Re: Retrieving Data from URL
by lshatzer (Friar) on May 13, 2002 at 14:54 UTC
    Check out LWP::Simple, it has a nice function getstore, where it will store the results in a file.
•Re: Retrieving Data from URL
by merlyn (Sage) on May 13, 2002 at 14:55 UTC
Incase You Need to Use a Proxy with LWP
by arunhorne (Pilgrim) on May 13, 2002 at 15:40 UTC

    Thanks, LWP worked brilliantly.

    Just as an aside for anyone looking at this thread in the future, I am behind a firewall and so had to add the following code to make it all work.

    use LWP::Simple qw(&getstore &is_success $ua);

    The above imports the $ua variable and the subs I needed, $ua (User Agent, see LWP::UserAgent) is used to set proxy settings.

    # Initialise the proxy $ua->proxy(http => 'http://wwwcache.ex.ac.uk:8080'); #$ua->proxy_authorization_basic( 'username', 'password' );

    The above actually sets the proxy. I didn't need any proxy auth, but you might, hence the line is there but commented out. Once this is done the subs like getstore worked great.

    Hope this helps in the future.

    Best wishes and thanks again, Arun

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-26 01:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found