The Wayback Machine - https://web.archive.org/web/20240717094012/https://www.geeksforgeeks.org/login-twitter-using-python-selenium/
Open In App

Login Twitter using Python Selenium

Last Updated : 04 Jan, 2021
Improve
Suggest changes
Post a comment
Like Article
Like
Save
Share
Report

Project Description:-
Here, we’re going to study a simple how-to log in twitter by selenium. Selenium is a free tool for automated trying out across exceptional browsers.

Requirement:

Below are the steps:

  • First, go to the twitter website using this Link.
  • Then click on investigate element by urgent ctrl + shift + i or stepping into setting of browser and clicking on investigate detail manually.
  • Then navigate box where Phone, email, or username are filled then copy the x_path.

  • Then navigate the Password then copy the x_path.

  • Then navigate the Login button then copy the x_path.

Below is the implementation:

One can replace the username and password for the account to be successfully logged in. Here the code is for demonstration only.




from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
  
# create instance of Chrome webdriver
driver = webdriver.Chrome() 
  
# find the element where we have to 
# enter the xpath
# fill the number or mail
driver.find_element_by_xpath('//*[@id ="react-root"]/div/div/div[2]/main/div/div/div[1]/form/div/div[1]/label/div/div[2]/div/input').send_keys('XXXXXX0418')
  
# find the element where we have to 
# enter the xpath
# fill the password
driver.find_element_by_xpath('//*[@id ="react-root"]/div/div/div[2]/main/div/div/div[1]/form/div/div[2]/label/div/div[2]/div/input').send_keys('PrXXXXXXXXX9')
  
# find the element log in 
# request using xpath 
# clicking on that element 
driver.find_element_by_xpath('//*[@id ="react-root"]/div/div/div[2]/main/div/div/div[1]/form/div/div[3]/div/div').click()


Output –
You will be logged in to twitter in the browser selenium has opened automatically.



Similar Reads

Twitter Automation using Selenium Python
If you are someone like me who considers Twitter to be far better than Instagram, then I might be having something for you. We all know gaining followers on twitter can be pretty tough but sometimes retweeting quality content can gain you, followers, too. Obviously, you are a busy person and you don't have time to sit around on your phone or laptop
6 min read
Gmail Login using Python Selenium
Python scripting is one of the most intriguing and fascinating things to do meanwhile learning Python. Automation and controlling the browser is one of them. In this particular article, we will see how to log in to the Gmail account using Python and the power of selenium. Selenium automates and controls browsers and it’s activity. We can code in ou
4 min read
How to access popup login window in selenium using Python
Many websites use sign-in using social media to make the login process easy for users. In most cases, if the button is clicked then a new popup window is opened where the user has to enter their user credentials. Manually one can switch windows in a browser and enter the required credentials to log in. But in case of unattended web access using a w
3 min read
Twitter Sentiment Analysis using Python
This article covers the sentiment analysis of any topic by parsing the tweets fetched from Twitter using Python. What is sentiment analysis? Sentiment Analysis is the process of 'computationally' determining whether a piece of writing is positive, negative or neutral. It’s also known as opinion mining, deriving the opinion or attitude of a speaker.
10 min read
twitter-text-python (ttp) module - Python
twitter-text-python is a Tweet parser and formatter for Python. Amongst many things, the tasks that can be performed by this module are : reply : The username of the handle to which the tweet is being replied to. users : All the usernames mentioned in the tweet. tags : All the hashtags mentioned in the tweet. urls : All the URLs mentioned in the tw
3 min read
Twitter Sentiment Analysis WebApp Using Flask
This is a web app made using Python and Flask Framework. It has a registration system and a dashboard. Users can enter keywords to retrieve live Twitter text based on the keyword, and analyze it for customer feelings and sentiments. This data can be visualized in a graph. This project, in particular, mines data using a popular “Tweepy” API. Tweepy
15+ min read
OAuth Authentication with Flask - Connect to Google, Twitter, and Facebook
In this article, we are going to build a flask application that will use the OAuth protocol to get user information. First, we need to understand the OAuth protocol and its procedure. What is OAuth? OAuth stands for Open Authorization and was implemented to achieve a connection between online services. The OAuth Community Site defines it as “An ope
8 min read
Create MySQL Database Login Page in Python using Tkinter
Prerequisites: Python GUI – tkinter, Python MySQL – Select QueryTkinter is one of the Python libraries which contains many functions for the development of graphic user interface pages and windows. Login pages are important for the development of any kind of mobile or web application. This page is most essential for user authentication purposes.We
2 min read
Login Application and Validating info using Kivy GUI and Pandas in Python
Prerequisites : Kivy, Pandas Kivy is a multiplatform GUI library, known for being responsive. It provides management of multiple screens in a single application. In this application we will be using multiple screens to log in user's info and validate it. We will save the information in a csv file and use pandas to validate the information inside of
5 min read
Create a Modern login UI using CustomTkinter module in Python
In this article, we will see how we can create a simple modern login UI using the customtkinter module in Python. customtkinter is a module that is purely built upon the Tkinter module, which helps the developers to create modern UI which was not possible with the traditional Tkinter module. It supports various new, modern, and fully customizable w
5 min read
three90RightbarBannerImg