npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

scraper-twitter

v1.3.0

Published

A Node.js module to extract details of a specified user's last tweet, including account information.

Downloads

25

Readme

Scraper Twitter

This module allows you to retrieve information from the latest tweet posted by a specific user. It also provides general information about the user, such as the number of followers, the number of subscriptions, etc.

Installation

To install this module, use the following command:

npm install scraper-twitter

Dependencies for Debian Users

If you are on Debian, you may need to install additional packages for Puppeteer to work correctly. Run the following command to install the required dependencies:

sudo apt install libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libgbm1 libasound2 libpangocairo-1.0-0 libxss1 libgtk-3-0

Source of Dependencies

Usage

To use this module, import it and call the scraperTweet function with the username of the account as an argument (without the @):

const scraperTweet = require('scraper-twitter');

scraperTweet('lan7ium').then(data => {
    console.log(data);
});

Additionally, in your project, remember to put your auth_token in your .env file.

auth_token= L'auth token de votre compte Twitter.

Retrieve the auth_token

To get your auth_token, go to this page, you must log in unless you are already logged in. Press CTRL + F12, then go to Storage (Firefox) / Application (Chrome and Edge), go to Cookies > https://x.com > auth_token, and you can now copy your auth_token and paste it into your .env file.

Return

The scraperTweet function returns an object containing the following information:

  • tweetText : Text of the latest tweet. (May be empty)
  • tweetLink : URL of the latest tweet.
  • tweetTime : Publication date of the latest tweet.
  • gifURL : Array containing the URL(s) of the GIF(s) in the latest tweet. (May be empty)
  • imgURLs : Array containing the URLs of the images in the latest tweet. (May be empty)
  • username : Display name of the user. (=/= @username)
  • bio : User's biography. (May be empty)
  • following : Number of users followed by the user.
  • followers : Number of the user's followers.
  • profileImageUrl : URL of the user's profile picture.

Example Output

Here is an example output of the scraperTweet function:

{
    "tweetText": "I am a tweet!",
    "tweetLink": "https://x.com/lan7ium/status/1234567890123456789",
    "tweetTime": "2020-03-01T00:00:00.000Z",
    "gifURL": [],
    "imgURLs": [
        "https://pbs.twimg.com/media/ERG0Q0VXkAAZ0ZS.jpg"
    ],
    "username": "lan7ium",
    "bio": "I am a bio!",
    "following": 42,
    "followers": 1337,
    "profileImageUrl": "https://pbs.twimg.com/profile_images/1234567890123456789/abcdefghijklmnopqrstuvwxyz1234567890"
}

Licence

This project is under WTFPL license - see WTFPL website for more details.