Skip to content

Latest commit

 

History

History
85 lines (53 loc) · 2.64 KB

README.md

File metadata and controls

85 lines (53 loc) · 2.64 KB

Tweet Search and Block Bot

This Python project automates the process of searching for tweets containing specific phrases and blocking users based on the similarity of the tweet text. It uses Selenium to interact with the X (formerly Twitter) platform. The bot can log in, search for tweets, and block users whose tweets match a certain similarity threshold.

Requirements

To run this project, you need the following:

  • Python 3.7+
  • Selenium WebDriver
  • Chrome browser
  • WebDriver Manager

Installation

  1. Clone the repository:

    git clone https://github.com/mertcanureten/x-tweet-blocker.git
    cd x-tweet-blocker
  2. Install the required dependencies:

    Install the required Python libraries by running:

    pip install -r requirements.txt
  3. Setup ChromeDriver:

    This script uses the webdriver_manager to install and manage the Chrome WebDriver. Make sure you have Chrome installed on your machine.

Usage

  1. Edit the login credentials:

    Update the USERNAME and PASSWORD variables in the script with your X platform credentials.

    USERNAME = 'your_username'
    PASSWORD = 'your_password'
  2. Run the script:

    You can run the script from the command line with the following arguments:

    python main.py --query "partial tweet text" --threshold 0.5
    • --query: A part of the tweet text you want to search for.
    • --threshold: (Optional) The minimum similarity threshold between the target tweet part and the actual tweets (default: 0.4).
  3. Cookie-based login:

    The first time you run the script, it will log in to X using the provided credentials and save the cookies in a file (x_cookies.pkl). On subsequent runs, the bot will load these cookies to avoid logging in every time.

Features

  • Automated login: Logs into the X platform using provided credentials.
  • Cookie management: Stores and loads cookies for faster future logins.
  • Tweet search: Searches for tweets containing a specified phrase.
  • User blocking: Blocks users whose tweets match the similarity threshold.

Example

Here’s an example of how to run the script:

python main.py --query "Hello World" --threshold 0.6

This will search for tweets containing "Hello World" and block users if their tweet text has a similarity of 60% or more.

Notes

  • Use this bot responsibly and in accordance with the terms and conditions of the X platform.
  • The script assumes that the UI of X remains unchanged. If any UI changes are made, you may need to update the XPaths used in the script.

License

This project is licensed under the MIT License.