1

I want to connect to my webvewier with Python using the requests module but I have a password set upon connection enter image description here

How do I make it so python puts in the password? When I look there is nothing being sent to the server making me think it's all in the browser.

fiji
  • 32
  • 10
  • 2
    this will help https://stackoverflow.com/questions/11892729/how-to-log-in-to-a-website-using-pythons-requests-module – deadshot Jul 05 '20 at 06:20

1 Answers1

0

I actually wrote a code that did something similar, with help from various forums. I'm going to put in false user and pass for obvious reasons, as the lines here are to demonstrate, I have no clue if thats the google login url.

import requests
url = 'https://www.google.com/login' #the address of the server youre logging into
username = 'foo@gmail.com' #your username
password = 'bar' #your password
requests.Session().get(url)
login_data = dict(USERNAME=username, PASSWORD=password)#Important; not all sites use USERNAME and PASSWORD, use chrome console to check
requests.Session().post(url, data=login_data)
page = requests.Session().get("https://www.google.com")#you can export the page html to a string like this, I'm supposing youre doing something else

Any variable of course can have any name, its only in the dictionary that USERNAME and PASSWORD have to be changed to something specific.

WCJ277
  • 31
  • 7