Skip to content

Commit

Permalink
renamed several methods and added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyapt committed Oct 2, 2016
1 parent 1df866e commit 8660198
Show file tree
Hide file tree
Showing 6 changed files with 318 additions and 13 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
*.swp
*.out
node_modules/
tmp/
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*~
*.lock
*.DS_Store
*.swp
*.out
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# insta-scraper
Node.js module for getting basic data from instagram without logging
Node.js module for getting basic data from instagram without login

## Installation
```
Expand All @@ -8,23 +8,23 @@ soon

## Usage
```
var scraper = require('scraper');
var scraper = require('insta-scraper');
```
**insta-scraper** offers these promise methods:
```
scraper.getAccountInfo(username, function(response_json){ })
```

```
scraper.getAccountMedias(username, [max_id], function(response_json){ })
scraper.getAccountMedia(username, [max_id], function(response_json){ })
```

```
scraper.getMediasByTag(tag, [max_id], function(response_json){ })
scraper.getMediaByTag(tag, [max_id], function(response_json){ })
```

```
scraper.getMediasByLocationId(locationId, [max_id], function(response_json){ })
scraper.getMediaByLocationId(locationId, [max_id], function(response_json){ })
```

```
Expand Down
10 changes: 6 additions & 4 deletions insta-scraper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Created by ilyapt on 30/09/16.
*/

'use strict';

var request = require('request');

exports.getAccountInfo = function(username, cb){
Expand All @@ -12,7 +14,7 @@ exports.getAccountInfo = function(username, cb){
};


exports.getAccountMedias = function(username, param2, param3){
exports.getAccountMedia = function(username, param2, param3){
var cb, maxid;
if(!param3){ cb = param2; maxid = ''; }else{ cb = param3; maxid='&max_id=' + param2; }
getInstaJson('https://www.instagram.com/' + username + '/media/?__a=1' + maxid
Expand All @@ -22,7 +24,7 @@ exports.getAccountMedias = function(username, param2, param3){
};


exports.getMediasByTag = function(tag, param2, param3){
exports.getMediaByTag = function(tag, param2, param3){
var cb, maxid;
if(!param3){ cb = param2; maxid = ''; }else{ cb = param3; maxid='&max_id='+param2; }
getInstaJson('https://www.instagram.com/explore/tags/' + encodeURIComponent(tag) + '/?__a=1' + maxid
Expand All @@ -32,7 +34,7 @@ exports.getMediasByTag = function(tag, param2, param3){
};


exports.getMediasByLocationId = function(locationId, param2, param3){
exports.getMediaByLocationId = function(locationId, param2, param3){
var cb, maxid;
if(!param3){ cb = param2; maxid = ''; }else{ cb = param3; maxid='&max_id='+param2; }
getInstaJson('https://www.instagram.com/explore/locations/' + locationId + '/?__a=1' + maxid
Expand Down Expand Up @@ -76,4 +78,4 @@ function getInstaJson(url,cb){
cb(null, json);
}
});
}
}
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "insta-scraper",
"version": "1.0.0",
"description": "Node.js module for getting basic data from instagram without logging",
"version": "1.0.1",
"description": "Node.js module for getting basic data from instagram without login",
"main": "insta-scraper.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "node_modules/.bin/mocha -r should --reporter spec tests/scraper-test.js"
},
"repository": {
"type": "git",
Expand All @@ -21,5 +21,9 @@
"homepage": "https://github.com/ilyapt/insta-scraper#readme",
"dependencies": {
"request": "^2.75.0"
},
"devDependencies": {
"mocha": "^1.7.0",
"should": "^1.2.1"
}
}
Loading

0 comments on commit 8660198

Please sign in to comment.