Auto Login Bot Using Python
Hi, everyone in this post I will tell you how you can make an Auto-Login Bot in Python.
This will automatically log in to your account on a specific site when you run this code.
We need this because it is very annoying, after a certain time we have to log-in after the timeout.
So, Let’s start. We require gecko driver for the specific browser, so download the driver for the browser you are using.
Python provides us with the module name selenium.
Before going through the post please read about selenium module and its function because without that you will not get this post.
To download the drivers go to the link below because we need this in our project.
https://selenium-python.readthedocs.io/installation.html#introduction
From selenium we require Web-driver.
This code is coded for the Mozilla Firefox. If you want then just change the browser name.
Python program: Auto Login Bot
from selenium import webdriver # Used to import the driver def bot(usr,pas): br=webdriver.Firefox() # you can import driver for any browser but install geckodriver for thet browser br.get("Enter your link") user=br.find_element_by_css_selector("#Enter the id name of id box using inspect") user.clear() user.send_keys(usr) # Fill the email box by given username or email id pasd=br.find_element_by_css_selector("#Enter the id name of password box using inspect") pasd.clear() pasd.send_keys(pas) # Fill the password filled by given password btn=br.find_element_by_css_selector("#Enter the id name of login button using inspect") btn.click() # Auto click the button #main driver code bot(" enter your id "," enter your password ")
In user, we have to enter the user id from the inspect of the website on which you want to login.
Do the same for the password field.
And the rest of the instructions are in the comments in the program itself.
Also read:
I entered the required link and id name but it gave an error
selenium.common.exceptions.InvalidSelectorException: Message: Given css selector expression “Sign in” is invalid: InvalidSelectorError: Document.querySelector: ‘Sign in’ is not a valid selector: “Sign in”
Please HELP me out.