Skip to content

Automation: Automatically login to any website

Hello Peeps,

I have got something exciting for today. Back into my working days, I needed to regularly punch in and punch out to my office website that would track my work of arrival and work of departure. Remind you– I should not be late than 9:00 am. The a thought came into my mind. Lets automate it. So here i am sharing my trips and tricks to you.

You need to have python installed in your machine. If you don’t know how to install python, the documentation of python is very straight forward. Please check the documentation here.

Then you need to install selenium chrome driver. You can get the selenium web driver from here. Please make sure the chrome version installed on your PC is the same as the chrome driver version you download. For example, My chrome and chrome driver both have version 83 at this point of writing. Download it and unzip it in some location that we are going to refer it later.

Here, you need to install two libraries selenium and explicit.

pip install explicit
pip install selenium

Here is the 9 lines of magic python code that will let you login in any website.

from explicit import waiter, XPATH
from selenium import webdriver

driver = webdriver.Chrome( executable_path='path upto chromedriver.exe')

username = "Your username"  # <username here>
password = "Your Password"  # <password here>

# Load page
driver.get("website here")

# Login
waiter.find_write(driver, "//input[@name='username']", username, by=XPATH)
waiter.find_write(driver, "//input[@name='password']", password, by=XPATH)
waiter.find_element(driver, "//button[@type='submit']", by=XPATH).click()


Check this out. I logged into my instagram account: The Tech Yoda in a blink of an eye.

Automatic Login to Instagram

With the code above, you can login to any sites. Just give a try and let me know if you have any difficulties.

Published inUncategorized

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *