Skip to main content

Twitter Scraper Tool

The Twitter Scraper Tool is a custom tool that allows the Newsletter AI Agent to collect tweets related to a specified topic using the Apify Twitter Scraper Lite actor.

Overview

The Twitter Scraper Tool is primarily used by the Researcher Agent to gather social media insights about the specified topic. It provides a flexible interface for searching Twitter and extracting structured data from tweets.

Implementation

The Twitter Scraper Tool is implemented as a CrewAI BaseTool that interacts with the Apify Twitter Scraper Lite actor. Here’s the implementation:

Parameters

The Twitter Scraper Tool accepts the following parameters:

Usage

The Twitter Scraper Tool is used by the Researcher Agent to gather social media insights about the specified topic:

Return Value

The tool returns a list of tweets, where each tweet is a dictionary containing information about the tweet, including:
  • text: The text content of the tweet
  • url: The URL of the tweet
  • username: The username of the tweet author
  • timestamp: The timestamp when the tweet was posted
  • likes: The number of likes the tweet received
  • retweets: The number of retweets the tweet received
  • Additional metadata about the tweet

Apify Integration

The tool uses the Apify Twitter Scraper Lite actor, which provides several advantages:
  1. Scalability: The actor can handle large numbers of Twitter searches efficiently
  2. Reliability: The actor is designed to handle rate limiting and other issues that can arise when scraping Twitter
  3. Structured Data: The actor returns tweets in a structured format that is easy to process
  4. No API Key Required: Unlike the official Twitter API, the actor doesn’t require API keys for basic functionality

Configuration

To use the Twitter Scraper Tool, you need to set up the following environment variables:

Next Steps