A Python-based tool for scraping Twitter timelines and extracting tweet data efficiently.
Before using this tool, please be aware of the following security considerations:
-
API Key Security:
- Never commit your
.envfile to version control - Keep your GROQ API key secure and rotate it if compromised
- Monitor your API usage for any unauthorized access
- Never commit your
-
Chrome Profile Security:
- The tool uses your Chrome profile to access Twitter
- This means it has access to your Twitter session
- Use a separate Chrome profile for scraping to limit access to your main account
- Never share your Chrome user data directory
-
Twitter Terms of Service:
- This tool is for educational purposes only
- Ensure you comply with Twitter's Terms of Service
- Do not use this tool for:
- Mass scraping
- Automated posting
- Data collection for commercial purposes without permission
- Any activity that could harm Twitter's services
-
Best Practices:
- Use a dedicated Twitter account for testing
- Regularly clear your Chrome profile data
- Monitor your Twitter account for any suspicious activity
- Keep your ChromeDriver and Chrome browser updated
- Scrape tweets from user timelines
- Extract tweet content, metadata, and engagement metrics
- Save data in structured formats
- Handle rate limiting and pagination
- Configurable scraping parameters
- Python 3.8 or higher
- GROQ API key
- Google Chrome browser
- ChromeDriver (matching your Chrome version)
- Clone the repository:
git clone https://github.com/VinVirtual/Twitter-Timeline-Scrapper-FastAPI.git
cd Twitter-Timeline-Scrapper- Create and activate a virtual environment:
python -m venv venv
# On Windows
venv\Scripts\activate
# On Unix or MacOS
source venv/bin/activate- Install the required dependencies:
pip install -r requirements.txt- Create a
.envfile in the project root with the following configuration:
# API Keys
GROQ_API_KEY=your_groq_api_key_here
# Chrome Configuration
CHROME_USER_DATA_DIR=C:/Users/YourUsername/AppData/Local/Google/Chrome/User Data
CHROME_PROFILE_NAME=Default
CHROME_BINARY_LOCATION=C:/Program Files/Google/Chrome/Application/chrome.exe
CHROMEDRIVER_PATH=path/to/your/chromedriver.exe
GROQ_API_KEY: Your Groq API key for AI-powered tweet summarizationCHROME_USER_DATA_DIR: Path to your Chrome user data directoryCHROME_PROFILE_NAME: Chrome profile to use (usually "Default")CHROME_BINARY_LOCATION: Path to your Chrome browser executableCHROMEDRIVER_PATH: Path to your ChromeDriver executable
-
Chrome User Data Directory:
- Windows:
C:\Users\YourUsername\AppData\Local\Google\Chrome\User Data - MacOS:
~/Library/Application Support/Google/Chrome - Linux:
~/.config/google-chrome
- Windows:
-
Chrome Binary Location:
- Windows:
C:\Program Files\Google\Chrome\Application\chrome.exe - MacOS:
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome - Linux:
/usr/bin/google-chrome
- Windows:
-
ChromeDriver:
- Download the appropriate version from ChromeDriver website
- Place it in a known location and update
CHROMEDRIVER_PATHaccordingly
- Configure your scraping parameters in the script
- Run the scraper:
python scraper.pyThe scraper will generate output files containing the scraped tweet data in your preferred format.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
This tool is for educational purposes only. Please ensure you comply with Twitter's Terms of Service and API usage guidelines when using this scraper. The authors are not responsible for any misuse of this tool or any consequences resulting from such misuse.