Git Product home page Git Product logo

ig-scrap-cache's Introduction

ig-scrap-cache


search media using tag name, and cache that using redis

initial

var IgScrapCache = require('ig-scrap-cache')

var igScrap = new IgScrapCache({
  redis: {  
    //redis options
    port: 6379,
    host: '127.0.0.1'
  },
  config: {
    //optional, defaults
    force: false,
    cacheTime: 60*30,//30mins
    enableFirstTime: false
  }
})

CONFIGS

redis

config

config required etc default
force false force update, ignore cache false
cacheTime false cached time 30*60
aheadTime false enable caching time ahead of cached time 5*60
enableFirstTime false enable a loading at first time false

useage

search media by tags

//https://www.instagram.com/explore/tags/{{tab}}/ or tag
igScrap.getMediaByTag(tag_name/*or url*/, function (err, result) {
//result
})

search media by users

// https://www.instagram.com/{{userid}}/ or userid
igScrap.getMediaByUser(user/*or url*/, function (err, result) {
//result
})

search users

// https://www.instagram.com/{{userid}}/ or userid
igScrap.getUser(user/*or url*/, function (err, result) {
  var user = result.user
  var media = result.media
})

search media by users

it is unstable

// https://www.instagram.com/{{userid}}/ or https://www.instagram.com/explore/tags/{{tab}}
igScrap.getMedia(url, function (err, result) {
// result.thumbnails()
// result.standard()
//result
})

clear cache

//remove cache about cache time, cache result, not queue
igScrap.getMedia(url, function (err, result) {
  // result.thumbnails()
  // result.standard()
  //result
})

warning

In case of first time in search by tag, return empty array, use enableFirstTime option

#change log

1.1.0

  • tag_name, user can be repleaced as url
  • add method 'getMedia'

2.0.0

  • use namespace (IGSCRAPE)
  • add getUser, clearCache
  • crawling code is modularized

3.0.0

  • version up ig-scrap module

#test

  • npm test

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.