Python3 using requests to grab HTTP Auth Data

Peter Pearson pkpearson at nowhere.invalid
Wed Feb 1 14:11:33 EST 2017


On Wed, 1 Feb 2017 07:10:39 -0800 (PST), Νίκος Βέργος wrote:
> # Give user the file requested
> url = "http://superhost.gr/data/files/%s" % realfile
>  
> user, password = 'user', 'passwd'
>  
> r = requests.get( url, auth = (user, password) ) # send auth unconditionally
> r.raise_for_status()
>==========================
>
> How can i ASK the user for http auth data and store them isntead of
> giving them to the script?

Maybe like this?

  user = raw_input("User: ")
  password = raw_input("Password: ")

-- 
To email me, substitute nowhere->runbox, invalid->com.



More information about the Python-list mailing list