HTTPS log in with urllib2

后端 未结 3 1264
难免孤独
难免孤独 2021-02-09 22:27

I currently have a little script that downloads a webpage and extracts some data I\'m interested in. Nothing fancy.

Currently I\'m downloading the page like so:

3条回答
  •  后悔当初
    2021-02-09 22:54

    The requests module provides a modern API to HTTP/HTTPS capabilities.

    import requests
    
    url = 'https://www.someserver.com/toplevelurl/somepage.htm'
    
    res = requests.get(url, auth=('USER', 'PASSWORD'))
    
    status = res.status_code
    text   = res.text
    

提交回复
热议问题