Open In App

How to Build a Simple Auto-Login Bot with Python

Last Updated : 19 Oct, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we are going to see how to built a simple auto-login bot using python.

In this present scenario, every website uses authentication and we have to log in by entering proper credentials. But sometimes it becomes very hectic to login again and again to a particular website. So, to come out of this problem lets, built our own auto login bot using python.

We will be using Selenium (python library) for making the auto-login bot. Python Selenium library helps us to access all functionalities of Selenium WebDriver like Firefox, Chrome, Remote etc.

Installation

First of all, we have to install selenium using the below command:

pip install selenium

After successful installation of selenium, we also have to install chromedriver for accessing the chrome webdriver of selenium. You can download the same from here (Download version according to your system chrome version and according to your OS).

Make sure that you have noted the location where the chromedriver has been downloaded (as it is used in our python script). Now After downloading extract the zip file and please note the file location of the extracted file as we have needed it later in python code. (You can find the location by clicking on properties and then details).

Stepwise Implementation:

  • First of all import the webdrivers from the selenium library.
  • Find the URL of the login page to which you want to logged in.
  • Provide the location executable chrome driver to selenium webdriver to access the chrome browser.
  • Finally, find the name or id or class or CSS selector of username and password by right-clicking inspect on username and password.

Below is the implementation:

Python3




# Used to import the webdriver from selenium
from selenium import webdriver 
import os
 
# Get the path of chromedriver which you have install
 
def startBot(username, password, url):
    path = "C:\\Users\\hp\\Downloads\\chromedriver"
     
    # giving the path of chromedriver to selenium webdriver
    driver = webdriver.Chrome(path)
     
    # opening the website  in chrome.
    driver.get(url)
     
    # find the id or name or class of
    # username by inspecting on username input
    driver.find_element_by_name(
        "id/class/name of username").send_keys(username)
     
    # find the password by inspecting on password input
    driver.find_element_by_name(
        "id/class/name of password").send_keys(password)
     
    # click on submit
    driver.find_element_by_css_selector(
        "id/class/name/css selector of login button").click()
 
 
# Driver Code
# Enter below your login credentials
username = "Enter your username"
password = "Enter your password"
 
# URL of the login page of site
# which you want to automate login.
url = "Enter the URL of login page of website"
 
# Call the function
startBot(username, password, url)


Output:



Previous Article
Next Article

Similar Reads

How to Build a Twitter Bot to Post Latest Stock Update using Python
The stock market is volatile and changes rapidly so we are going to create a simple Twitter bot to post the latest stock updates using Python that posts the tweet about the stocks that users have chosen. First, let's understand the prerequisites of our project: Nsepython: It is a Python library to get publicly available data on the current NSEIndia
5 min read
How to Build Web scraping bot in Python
In this article, we are going to see how to build a web scraping bot in Python. Web Scraping is a process of extracting data from websites. A Bot is a piece of code that will automate our task. Therefore, A web scraping bot is a program that will automatically scrape a website for data, based on our requirements. Module neededbs4: Beautiful Soup(bs
8 min read
Build a simple Quantum Circuit using IBM Qiskit in Python
Qiskit is an open source framework for quantum computing. It provides tools for creating and manipulating quantum programs and running them on prototype quantum devices on IBM Q Experience or on simulators on a local computer. Let's see how we can create simple Quantum circuit and test it on a real Quantum computer or simulate in our computer local
5 min read
Google Chrome Dino Bot using Image Recognition | Python
What would you see in your Chrome browser when there is no internet connection? Yes, everybody knows that dinosaur game that comes on screen. So, in this article, we are going to build a simple python bot that plays Chrome Dino Game without user interaction. Here we are not using any machine learning or artificial intelligence to counter this probl
4 min read
Python | Whatsapp birthday bot
Have you ever wished to automatically wish your friends on their birthdays, or send a set of messages to your friend ( or any Whastapp contact! ) automatically at a pre-set time, or send your friends by sending thousands of random text on whatsapp! Using Browser Automation you can do all of it and much more!First you must install these:- 1) Python
9 min read
Chat Bot in Python with ChatterBot Module
Nobody likes to be alone always, but sometimes loneliness could be a better medicine to hunch the thirst for a peaceful environment. Even during such lonely quarantines, we may ignore humans but not humanoids. Yes, if you have guessed this article for a chatbot, then you have cracked it right. We won't require 6000 lines of code to create a chatbot
3 min read
How to make a Twitter Bot in Python?
Twitter is an American microblogging and social networking service on which users post and interact with messages known as "tweets". In this article we will make a Twitter Bot using Python. Python as well as Javascript can be used to develop an automatic Twitter bot that can do many tasks by its own such as: Retweets the tweets with particular #has
3 min read
Python - Making a Reddit bot with PRAW
Reddit is a network of communities based on people’s interests. Each of these communities is called a subreddit. Users can subscribe to multiple subreddits to post, comment and interact with them. A Reddit bot is something that automatically responds to a user’s post or automatically posts things at certain intervals. This could depend on what cont
2 min read
Instagram Bot using Python and InstaPy
In this article, we will design a simple fun project “Instagram Bot” using Python and InstaPy. As beginners want to do some extra and learning small projects so that it will help in building big future projects. Now, this is the time to learn some new projects and a better future. This python project gives the functionality of Instagram bot to like
3 min read
Building WhatsApp bot on Python
A WhatsApp bot is application software that is able to carry on communication with humans in a spoken or written manner. And today we are going to learn how we can create a WhatsApp bot using python. First, let's see the requirements for building the WhatsApp bot using python language. System Requirements:A Twilio account and a smartphone with an a
6 min read