1.0.0 • Published 2 months ago

x-tweet-grabber v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

X Tweet Grabber

X Tweet Grabber is an npm package that allows you to grab all the tweets from a specific account on X (formerly known as Twitter) using a user's cookie. It retrieves the timestamp and text content of the tweets and outputs them as a PDF file, sorted in chunks by time.

Installation

To install the package, run the following command:

npm install x-tweet-grabber

Usage

First, require the package in your JavaScript file:

const { grabTweets } = require('x-tweet-grabber');

Then, call the grabTweets function with the necessary options:

const options = {
  cookie: 'your_cookie_here',
  accountHandle: 'account_handle_here',
  outputDir: './output',
  timeInterval: 'monthly',
  headless: true,
};

grabTweets(options)
  .then(() => {
    console.log('Tweets grabbed and PDF generated successfully!');
  })
  .catch((error) => {
    console.error('Error:', error);
  });

Options

  • cookie (required): The user's cookie for authentication on X.
  • accountHandle (required): The handle of the account from which to grab tweets.
  • outputDir (optional, default: './output'): The directory where the generated PDF file will be saved.
  • timeInterval (optional, default: 'monthly'): The time interval for grouping tweets. Can be 'monthly' or 'yearly'.
  • headless (optional, default: true): Whether to run the browser in headless mode.

Output

The package will generate a PDF file named tweets_<accountHandle>.pdf in the specified output directory. The PDF will contain the grabbed tweets, sorted in chunks based on the specified time interval.

Dependencies

  • puppeteer: A library for controlling a headless Chrome or Chromium browser.
  • pdfkit: A library for creating PDF documents in Node.js.

License

This package is open-source and available under the MIT License.

1.0.0

2 months ago