urllib.request.urlopen(url) with Authentication

前端 未结 3 1225
庸人自扰
庸人自扰 2020-12-05 14:12

I\'ve been playing with beautiful soup and parsing web pages for a few days. I have been using a line of code which has been my saviour in all the scripts that I write. The

3条回答
  •  青春惊慌失措
    2020-12-05 14:48

    With urllib3 :

    import urllib3
    
    http = urllib3.PoolManager()
    myHeaders = urllib3.util.make_headers(basic_auth='my_username:my_password')
    http.request('GET', 'http://example.org', headers=myHeaders)
    

提交回复
热议问题