Login Instagram(with Facebook) – Selenium

Today, we come up with the script that helps you to access your Instagram with the help of Facebook sign in option.

First you must install these:-

1) Python Bindings for Selenium ( Browser Automation software )

pip install selenium

2) Chrome webdriver
Download Chrome driver from here: Chromedriver download page( choose your specific version )
Extract it in a known location , as we need the location later.

That’s it! You are all set.

Lets dive in right away-

from selenium import webdriver
import time
browser = webdriver.Chrome(r"C:\Users\Kishan Kumar\Assignment - Bored\Whatsapp Bot\chromedriver.exe")
url = 'https://www.facebook.com/login.php?skip_api_login=1&api_key=124024574287414&kid_directed_site=0&app_id=124024574287414&signed_next=1&next=https%3A%2F%2Fwww.facebook.com%2Fdialog%2Foauth%3Fclient_id%3D124024574287414%26redirect_uri%3Dhttps%253A%252F%252Fwww.instagram.com%252Faccounts%252Fsignup%252F%26state%3D%257B%2522fbLoginKey%2522%253A%2522j77osm158eupuwdg2eu1hxtbe316znozk116qhp7gzaigbqxvcop%2522%252C%2522fbLoginReturnURL%2522%253A%2522%252F%2522%257D%26scope%3Demail%26response_type%3Dcode%252Cgranted_scopes%26locale%3Den_US%26ret%3Dlogin%26fbapp_pres%3D0%26logger_id%3D1cdf9df7-2d2a-408e-9eee-8bd1f37cc37e&cancel_url=https%3A%2F%2Fwww.instagram.com%2Faccounts%2Fsignup%2F%3Ferror%3Daccess_denied%26error_code%3D200%26error_description%3DPermissions%2Berror%26error_reason%3Duser_denied%26state%3D%257B%2522fbLoginKey%2522%253A%2522j77osm158eupuwdg2eu1hxtbe316znozk116qhp7gzaigbqxvcop%2522%252C%2522fbLoginReturnURL%2522%253A%2522%252F%2522%257D%23_%3D_&display=page&locale=en_GB&pl_dbl=0'
username1 = '305kishan'
password1 = 'testpass'
browser.get(url)
time.sleep(2)
a = browser.find_element_by_name('email').send_keys(username1)
b = browser.find_element_by_name('pass').send_keys(password1)
browser.find_element_by_name('login').click()
time.sleep(2)
browser.find_element_by_class_name("_7UhW9.xLCgt.qyrsm.h_zdq.fDxYl.T0kll ").click()
time.sleep(2)
browser.find_element_by_class_name("aOOlW.HoLwm ").click()

Comment below about your experience!

When it comes to browser automation, this is just the tip of the iceberg. Will write more articles on browser automation to give you a glimpse of its power!

Published by 305kishan

Aspiring Data Scientist, Hardcore Gamer and Die Hard fan of Cristiano Ronaldo.

Leave a comment

Design a site like this with WordPress.com
Get started