Authentication And Python Requests
I am trying to download some documents using requests, but the page is redirecting me to a userlog in screen and therefor downloading the HTML page. I've tried doing: c=requests.ge
Solution 1:
Basically, it had to do with grabbing the authentication ID off the page and passing in cookies.
This is basically what I did:
from bs4 import BeautifulSoup as bs
import requests
s = requests.session()
url = r'url_i_care_about'defauthenticate(s, url):
headers = {'username': 'myuser', 'password': 'mypasss', '_Id': 'submit'}
page=s.get(url)
soup=bs(page.content)
value=soup.form.find_all('input')[2]['value']
headers.update({'value_name':value})
auth = s.post(url, params=headers, cookies=page.cookies)
Post a Comment for "Authentication And Python Requests"