New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

instagram-screen-scrape

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

instagram-screen-scrape - npm Package Compare versions

Comparing version 0.0.2 to 1.0.0

8

lib/cli.js

@@ -1,6 +0,6 @@

// Generated by CoffeeScript 1.8.0
// Generated by CoffeeScript 1.9.3
(function() {
var ArgumentParser, JSONStream, argparser, argv, packageInfo, scrape;
var ArgumentParser, InstagramPosts, JSONStream, argparser, argv, packageInfo;
scrape = require('./');
InstagramPosts = require('./');

@@ -27,4 +27,4 @@ packageInfo = require('../package');

scrape(argv).pipe(JSONStream.stringify('[', ',\n', ']\n')).pipe(process.stdout);
(new InstagramPosts(argv)).pipe(JSONStream.stringify('[', ',\n', ']\n')).pipe(process.stdout);
}).call(this);

@@ -1,4 +0,7 @@

// Generated by CoffeeScript 1.8.0
// Generated by CoffeeScript 1.9.3
(function() {
var H, JSONStream, Readable, W, getPostPage, request;
var InstagramPosts, JSONStream, Readable, getPosts, request,
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -11,7 +14,3 @@ Readable = require('readable-stream').Readable;

H = require('highland');
W = require('when');
/**

@@ -23,6 +22,6 @@ * Make a request for a Instagram page, parse the response, and get all the

from the last request), or undefined if this is the first request.
* @return {Array} A stream of posts
* @return {Stream} A stream of posts
*/
getPostPage = function(username, startingId) {
getPosts = function(username, startingId) {
var outStream;

@@ -47,3 +46,3 @@ outStream = JSONStream.parse('items.*');

/**
* Scrape as many posts as possible for a given user.
* Stream that scrapes as many posts as possible for a given user.
* @param {String} options.username

@@ -53,18 +52,43 @@ * @return {Stream} A stream of post objects.

module.exports = function(_arg) {
var output, scrape, username;
username = _arg.username;
output = new Readable({
objectMode: true
});
output._read = (function() {});
scrape = function(username, startingId) {
return W.promise(function(resolve, reject) {
var minId;
minId = null;
return H(getPostPage(username, startingId)).map(function(rawPost) {
InstagramPosts = (function(superClass) {
extend(InstagramPosts, superClass);
InstagramPosts.prototype._lock = false;
InstagramPosts.prototype._minPostId = void 0;
function InstagramPosts(arg) {
this.username = arg.username;
this.destroy = bind(this.destroy, this);
this._read = bind(this._read, this);
InstagramPosts.__super__.constructor.call(this, {
highWaterMark: 16,
objectMode: true
});
this._readableState.destroyed = false;
}
InstagramPosts.prototype._read = function() {
var hasMorePosts, lastPost;
if (this._lock) {
return;
}
this._lock = true;
if (this._readableState.destroyed) {
this.push(null);
return;
}
hasMorePosts = false;
lastPost = void 0;
return getPosts(this.username, this._minPostId).on('error', (function(_this) {
return function(err) {
return _this.emit('error', err);
};
})(this)).on('data', (function(_this) {
return function(rawPost) {
var post;
hasMorePosts = true;
post = {
id: rawPost.code,
username: username,
username: _this.username,
time: +rawPost['created_time'],

@@ -84,21 +108,48 @@ type: rawPost.type,

}
minId = rawPost.id;
return output.push(post);
}).on('error', function(err) {
return reject(err);
}).on('end', function() {
return resolve(minId);
}).toArray(function() {});
}).then(function(minId) {
if (minId != null) {
return scrape(username, minId);
} else {
output.push(null);
}
});
_this._minPostId = rawPost.id;
if (lastPost != null) {
_this.push(lastPost);
}
return lastPost = post;
};
})(this)).on('end', (function(_this) {
return function() {
if (hasMorePosts) {
_this._lock = false;
}
if (lastPost != null) {
_this.push(lastPost);
}
if (!hasMorePosts) {
return _this.push(null);
}
};
})(this));
};
scrape(username);
return output;
};
InstagramPosts.prototype.destroy = function() {
if (this._readableState.destroyed) {
return;
}
this._readableState.destroyed = true;
return this._destroy((function(_this) {
return function(err) {
if (err) {
_this.emit('error', err);
}
return _this.emit('close');
};
})(this));
};
InstagramPosts.prototype._destroy = function(cb) {
return process.nextTick(cb);
};
return InstagramPosts;
})(Readable);
module.exports = InstagramPosts;
}).call(this);
{
"name": "instagram-screen-scrape",
"description": "scrape public instagram data w/out API access",
"version": "0.0.2",
"version": "1.0.0",
"author": "Sean Lang <slang800@gmail.com>",

@@ -15,6 +15,4 @@ "bin": {

"argparse": "^1.0.2",
"highland": "^2.4.0",
"readable-stream": "^1.0.33",
"request": "^2.55.0",
"when": "^3.7.2"
"request": "^2.55.0"
},

@@ -28,3 +26,3 @@ "devDependencies": {

"homepage": "https://github.com/slang800/instagram-screen-scrape",
"license": "GPLv3",
"license": "GPL-3.0",
"main": "lib",

@@ -31,0 +29,0 @@ "repository": {

@@ -28,6 +28,6 @@ # Instagram Screen Scrape

```coffee
scrape = require 'instagram-screen-scrape'
InstagramPosts = require 'instagram-screen-scrape'
# create the stream
streamOfPosts = scrape(username: 'slang800')
streamOfPosts = new InstagramPosts(username: 'slang800')

@@ -53,6 +53,6 @@ # do something interesting with the stream

```js
var scrape, streamOfPosts;
scrape = require('instagram-screen-scrape');
var InstagramPosts, streamOfPosts;
InstagramPosts = require('instagram-screen-scrape');
streamOfPosts = scrape({
streamOfPosts = new InstagramPosts({
username: 'slang800'

@@ -59,0 +59,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc