tweet-harvest2
v4.4.1
Published
A Twitter crawler helper with auth
Downloads
1,095
Readme
Tweet Harvest (Twitter Crawler)
Tweet Harvest is a command-line tool that uses Playwright to scrape tweets from Twitter search results based on specified keywords and date range. The scraped tweets are saved in a CSV file.
Note: This script is for educational purposes only. Twitter prohibits unauthenticated users from performing search or advanced search. To use this script, you need to have a valid Twitter account and obtain an Access Token, which can be obtained by logging into Twitter in your browser and extracting the auth_token cookie.
How to Use
To use Tweet Harvest, follow these simple steps:
- Install Node.js (LTS) on your computer.
- Open your terminal or command prompt.
- Type
npx tweet-harvest@latestand press Enter. - Follow the prompts to provide the data you want to search for on Twitter, such as keywords, dates, and other parameters.
That’s it! Tweet Harvest will open a Chromium browser instance and navigate to Twitter's search page. It will then enter your search parameters and scrape the resulting tweets. The tweets will be saved in a CSV file in a directory named tweets-data in the current working directory.
Note: You will need a Twitter auth token to use this tool. When prompted, enter your Twitter auth token to authenticate your search.
Publishing tweet-harvest2 to npmjs (Step-by-step)
Prerequisites
- You have access to the npm package name:
tweet-harvest2 - Your code compiles to
dist/(because your package publishes onlydist/) - You have
pnpmandnpminstalled
1) Go to your project folder
cd /path/to/tweet-harvest22) Install dependencies
pnpm install3) Make sure you are logged in to npmjs
Check login:
npm whoamiIf it errors, login:
npm login(Optional) confirm registry points to npmjs:
npm config get registry
# should be: https://registry.npmjs.org/4) Build the project (generate dist/)
pnpm buildVerify output exists:
ls distAlso verify the CLI entry exists (important):
ls dist/bin.js5) Bump the version
You MUST bump version before publishing (npm won’t allow re-publishing the same version).
Choose ONE:
- Patch (bugfix):
npm version patch- Minor (new features, backward-compatible):
npm version minor- Major (breaking changes):
npm version majorThis updates package.json and creates a git commit + tag.
6) Publish to npmjs
npm publishNote: Your
package.jsonincludes"prepublish": "pnpm build", sonpm publishwill run the build again automatically.
7) Verify the published version
npm view tweet-harvest2 versionOptional: test install in a fresh place
npm i -g tweet-harvest2
tweet-harvest --help8) Push git commits & tags (recommended)
If you use git:
git push --follow-tagsCommon errors & fixes
Error: "You cannot publish over the previously published versions"
Fix: bump version again, then publish:
npm version patch
npm publishCLI installed but command fails
Fix: ensure dist/bin.js exists and is included:
pnpm build- check
dist/bin.js - publish again (with a new version)
