![]() |
Login through a protected directory - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Login through a protected directory (/thread-34358.html) |
Login through a protected directory - ebolisa - Jul-23-2021 Hi, I've an index.html page stored in a protected folder, how do I get to it? The code below doesn't work. TIA import requests url='https://mypage.com/private/index.html' values={'username':'user','password':'pass'} r=requests.post(url, data=values) print(r.content) RE: Login through a protected directory - Larz60+ - Jul-24-2021 try: url = 'file:///private/index.html' the part after file/// needs to be full path RE: Login through a protected directory - ebolisa - Jul-24-2021 Thank you, will try. However, it’s a web folder and it may use .haccess as a security gate. RE: Login through a protected directory - ebolisa - Jul-24-2021 Solved. Here's the code: import requests import urllib3 urllib3.disable_warnings() URL = 'https://www.mypage.com/private/' HTACCESS_USER = 'me' HTACCESS_PASSW = 'mypass' data = requests.get(URL, verify = False, auth = (HTACCESS_USER, HTACCESS_PASSW)) print(data.text) # passed .htaccess, perfect! now on login page |