Coder Social home page Coder Social logo

instagram-feed-watcher's Introduction

TypeScript Instagram Feed Scraper

A TypeScript library for scraping Instagram feeds.

Installation

npm install instagram-feed-scraper

Usage

const { Watcher } = require("instagram-feed-scraper");

// Optional: Provide configuration options
const options = {
  userAgent: "Custom User Agent",
  cookieFilePath: "/path/to/your/cookies.txt", // Where to store session cookies (default: "../resources/cookies.txt")
  pollingInterval: [54_000, 72_000], // Time between each feed refresh (default: [54_582, 71_845])
  maxRetries: 3, // Maximum number of retries before crashing (default: 3)
  retryCooldown: [7000, 14_000], // Time between retries (default: [7352, 13_791])
};

const watcher = new Watcher(username, password, options); // Create a new Watcher instance

// Watch for new posts
const stopWatching = watcher.watch((post) => {
  // This callback will be called whenever a new post is found
  console.log(post);
});

// Or just retrieve the first 4 posts from the Following feed
watcher.get().then((posts) => {
  posts.forEach((post) => {
    console.log(post); // Access posts
  });
});

stopWatching(); // Remove listener

watcher.destroy(); // Remove all listeners and stop refreshing feed

API Reference

Watcher

constructor(username: string, password: string, options?: Partial<WatcherOptions>): Watcher

Creates a new Watcher instance.

  • username: Your Instagram username.
  • password: Your Instagram password.
  • options (optional): Configuration options.

get(): Promise<Post[]>

Retrieves the first 4 posts from the Following feed.

Returns an array of posts.

watch(listener: (post: Post) => void): () => void

Calls listener for every new post found.

  • listener: Function to be called whenever a new post is found.

Returns a function that removes the listener.

destroy(): void

Remove all watchers and stop refreshing feed

instagram-feed-watcher's People

Contributors

lucassilvas1 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.