K. John
K. John

Reputation: 31

Python Request Popup Auth

from requests.auth import HTTPDigestAuth
import requests
url = "http://128.11.1.2/cgi-bin/allconf.cgi?getdata"
r = requests.get(url, auth=HTTPDigestAuth('test', 'test'))
print(r)

When I go to that URL, it shows as Response 401 even though username and password are correct. If I do it manually on the chrome browser to that specific URL and login, it works fine.

Is there any way I can fix this? So I can start scraping all the information using BeautifulSoup which I am familiar with.

Upvotes: 3

Views: 4895

Answers (1)

Drakesword
Drakesword

Reputation: 11

Have you tried using this instead? ( This uses basic auth )

requests.post('url', auth=('test', 'test'))
<Response [200]>

The authentication depends on the type of authentication that you are using.

Check this link for more auth types that match what you maybe using.

http://docs.python-requests.org/en/master/user/authentication/

Upvotes: 1

Related Questions