Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

How do I download a file that needs username and password?

by Zork2 (Initiate)
on Feb 21, 2021 at 13:13 UTC ( #11128620=perlquestion: print w/replies, xml ) Need Help??

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

Hi

I am trying to download some JSON files from URLs of the form:

https://stt.disruptorbeam.com/player?client_api=N

Where N is an integer, eg

https://stt.disruptorbeam.com/player?client_api=1

But i get sent to a login screen.

In a web browser this is fine, you just click the "Sign in with Dbid" link, then enter your username and password, after which the URLs will work.

However i have absolutely no idea how to do this in perl.

Any help would be appreciated.

Thanks

Replies are listed 'Best First'.
Re: How do I download a file that needs username and password?
by LanX (Sage) on Feb 21, 2021 at 13:54 UTC
Re: How do I download a file that needs username and password?
by 1nickt (Canon) on Feb 21, 2021 at 13:20 UTC

    Hi, you could automate your login with WWW::Mechanize or one of its subclasses.

    Hope this helps!


    The way forward always starts with a minimal test.
Re: How do I download a file that needs username and password?
by Anonymous Monk on Feb 21, 2021 at 13:18 UTC
Re: How do I download a file that needs username and password?
by Bod (Curate) on Feb 21, 2021 at 19:40 UTC

    Like LanX, I would (probably) use LWP for this task depending on the complexity of the site's login system.

    You probably want to look at the documentation for enabling cookies.

Re: How do I download a file that needs username and password?
by Zork2 (Initiate) on Feb 22, 2021 at 15:43 UTC
    Thanks everyone! I'll take another look at LWP, but WWW::Mechanize looks very promising.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11128620]
Approved by 1nickt
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2022-05-16 08:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (62 votes). Check out past polls.

    Notices?