A Twitter web scraper built with TypeScript and Puppeteer
To use this package in your project, run:
npm i twitter-webscraper
- Log in to your Twitter account
- Scrape tweets
- Scrape user's information
- Scrape user's followers
- Scrape user's following
- Search and Scrape top and latest tweets
- Scrape logged in user's timeline
- Scrape user's tweets
const { Scraper } = require('twitter-webscraper');
const scraper = new Scraper();
(async () => {
// It will initialize the headless browser
await scraper.initializeBrowser();
// It's not necessary to log in, but if you want to have access to
// all of the features, then you need to log in.
await scraper.login('username or email', 'password');
const userInfo = await scraper.getUserInfo('username');
console.log(userInfo);
// It will close the headless browser.
// You have to write this at the end of your code.
scraper.browser.close();
})();
Method | Description |
---|---|
initializeBrowser() |
It will initialize the headless browser |
login(username_or_email: string, password: string) |
Log in to your Twitter account |
getUserInfo(username: string) |
Scrape information of the given user |
getFollwers(username: string) |
Scrape followers of the given user |
getFollwing(username: string) |
Scrape following of the given user |
getTweet(link: string) |
Scrape the given tweet |
browser.close() |
It will close the headless browser |
If you encounter a bug or you want to add new features, feel free to submit issues and enhancement requests.
- Fork the repo on GitHub
- Clone the project to your own machine
- Commit changes to your own branch
- Push your work back up to your fork
- Submit a Pull request