Skip to content

bishwa-poudel/twitter-automation-using-selenium-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Twitter automation using Selenium Java

Just Another web automation project 😁😁

Get connected on LinkedIn Follow on LinkedIn


About The Project

I have had some issues regarding the application of Twitter developer account, as it was constantly being rejected citing minor issues. At last I finally geared up doing the same, but using different approach. This project explores Selenium as a Web Automation tool that automates Twitter Login, Logout and Likes and can serve as a base for doing other automations in twitter.

Disclaimer

This project is purely intended for educational purpose with not to be used in production environment. Many actions automated here goes against Twitter policy, and this project by any means doesn't intend to violate those policies. Please go through Twitter automation policies before actually using this code. Link: Twitter Developer Policy

Built With

  • Java 8 as programming language
  • Maven for Package Management and Build Automation
  • Selenium for Web Automation
  • Resteasy as JAX-RS implementation for Restful Services

Getting Started

Prerequisites

Basic understanding of Java with Maven.

Running the project

Steps are listed below to get this project up and running in your development environment.

  • Setup Java with JDK 1.8. For reference: Use this official Tutorial
  • Setup Maven. Follow this link: Maven Setup
  • Clone this repository in your target folder.
git clone https://github.com/bishwa-poudel/twitter-automation-using-selenium-java.git
  • Now go to src/main/resources/twitter.sample.properties and rename the configuration file to twitter.properties. And fill the params listed in properties file.

Example:

# file: twitter.properties
#******************************** Twitter account creds ********************************
USERNAME=your_username
PASSWORD=your_password


#******************************** Automation Rate ********************************
LIKE_LIMIT=100
DELAY_IN_MS=3000
REPEAT_AFTER_IN_MINUTES=180


#************************ Twitter Feed URL (with any filters or hashtags) ********************************
TWITTER_FEED_URL=twitter_feed_url
  1. USERNAME: Your twitter account username
  2. PASSWORD: Your twitter account password (Credentials are purely used for login to twitter.)
  3. LIKE_LIMIT: Number of likes that should be done in one cycle.
  4. DELAY_IN_MS: You donot want to spam twitter with multiple requests at a single time right. To simulate the human behavior, we are adding some delay after every action in automation.
  5. REPEAT_AFTER_IN_MINUTES: The time interval at which the particular action is to be repeated. Ex: 180 denotes Like action will repeat in every 180 minutes
  6. TWITTER_FEED_URL: URL of twitter timeline. This might be twitter homepage, timeline of particular hashtags or using any advanced filtering. The URL should open to the tweets timeline.
  • After you are sure that everything is setup correctly, run maven build command:
mvn clean install

image

  • Once you see this message in the console, your build is ready. Goto target/twitter-automation.war to get the WAR file.

Note: I have used WAR for packaging. If you want to build into the jar file, change the <packaging> inside pom.xml file to jar.

 <packaging>jar</packaging>

Now you can use any application server to deploy the archived java file. For this project I am using Wildfly v22.0.1

Congrats !!! You are now able to run and deploy the project in your own development environment.

Usage

Server automatically schedules Twitter Like Action based on the time interval mentioned on twitter.properties file. There is also APIs exposed for manual login, logout and like actions.

For Manual Login

GET /twitter-automation/api/action/login

For Automating Likes

GET /twitter-automation/api/action/like

For Manual Logout

GET /twitter-automation/api/action/logout

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Contact

LinkedIn Twitter

About

Trying to automate daily twitter activities using Selenium in Java

Topics

Resources

License

Stars

Watchers

Forks

Languages