Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

user-instagram

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

user-instagram - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

src/handle.js

18

index.js

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

const request = require("request-promise")
const { getData } = require("./src/scrape")
function scrape(url) {
return new Promise((resolve, reject) => {
request(url).then(data => {
resolve(getData(data))
}).catch(e => {
reject(e)
})
})
}
const handle = require("./src/handle");
module.exports = scrape
/**
* @param profileInfo { String }
*/
module.exports = handle;
{
"name": "user-instagram",
"version": "1.0.4",
"description": "Get user data and feed by scraping Instagram's user page. No need for O-Auth or API.",
"version": "1.1.0",
"description": "Get user data and feed content by scraping Instagram's user page. No OAuth needed.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "node test/test.js"
},

@@ -24,6 +24,5 @@ "keywords": [

"dependencies": {
"cheerio": "^1.0.0-rc.3",
"request": "^2.88.0",
"request-promise": "^4.2.4"
"axios": "^0.19.2",
"cheerio": "^1.0.0-rc.3"
}
}
# Node-Instagram
[![NPM](https://nodei.co/npm/user-instagram.png)](https://nodei.co/npm/user-instagram)
This module allow you to get user data from instagram link.
<b>Example:</b>
## Introduction
The aim of this module is to provide an easy way to retrieve a user's Instagram data.
This module is available on NPM.
```
npm install user-instagram
```
## Usage
I tried to make this module user-friendly as much as I could. Just provide a username or a profile link.
> edouard_courty
> https://www.instagram.com/edouard_courty
```js
const instagram = require("user-instagram")
const getInstaProfile = require("user-instagram");
instagram("https://www.instagram.com/edouard_courty")
.then(data => {
console.log(`Full name is: ${data.fullName}`)
})
.catch(e => {
// Error will trigger if the account link provided is false.
console.error(data)
})
getInstaProfile("edouard_courty")
.then(userData => {
console.log(userData.user)
})
.catch(console.error);
```
This module only uses ES6 Promises.
By the future, i'll update this module to add methods.
## Data Structure
[Creator's website](https://edouard-courty.fr)
The output will look like the following:
```json
{
profileLink: 'https://www.instagram.com/edouard_courty',
subscriberCount: 444,
subscribtions: 362,
postCount: 27,
username: 'edouard_courty',
isPrivate: false,
isVerified: false,
fullName: 'Edouard Courty',
bio: "<userBio",
id: '<userId>',
avatar: <avatarThumbnailLink>,
avatarHD: <HDAvatarLink>,
posts: []
}
```
This module uses ES6 Promises.
© 2020 - Edouard Courty

@@ -1,53 +0,56 @@

const cheerio = require("cheerio")
const cheerio = require("cheerio");
function getData(body) {
var $ = cheerio.load(body)
var scripts = $("script[type='text/javascript']")
var sharedData = JSON.parse(
scripts[3].children[0].data
.replace("window._sharedData = ", "")
.replace("};", "}")
)
var graphql = sharedData.entry_data.ProfilePage[0].graphql.user
return {
"profileLink": "https://www.instagram.com/".concat(graphql.username),
"subscriberCount": graphql.edge_followed_by.count,
"subscribtions": graphql.edge_follow.count,
"postCount": graphql.edge_owner_to_timeline_media.count,
"username": graphql.username,
"isPrivate": graphql.is_private,
"isVerified": graphql.is_verified,
"fullName": graphql.full_name,
"bio": graphql.biography,
"id": graphql.id,
"postCount": graphql.edge_owner_to_timeline_media.count,
"avatar": graphql.profile_pic_url,
"avatarHD": graphql.profile_pic_url_hd,
"posts": graphql.edge_owner_to_timeline_media.edges.map(edge => {
return {
"id": edge.node.id,
"captionText": edge.node.edge_media_to_caption.edges.length === 0 ? null : edge.node.edge_media_to_caption.edges[0].node.text,
"shortcode": edge.node.shortcode,
"link": `https://www.instagram.com/p/${edge.node.shortcode}`,
"commentsCount": edge.node.edge_media_to_comment.count,
"timestamp": edge.node.taken_at_timestamp,
"likes": edge.node.edge_liked_by.count,
"location": edge.node.location || null,
"picture": {
"url": edge.node.thumbnail_src,
"thumbnail_150": edge.node.thumbnail_resources[0].src,
"thumbnail_240": edge.node.thumbnail_resources[1].src,
"thumbnail_320": edge.node.thumbnail_resources[2].src,
"thumbnail_480": edge.node.thumbnail_resources[3].src,
"thumbnail_640": edge.node.thumbnail_resources[4].src
},
"isVideo": edge.node.is_video
}
module.exports = body => {
return new Promise((resolve, reject) => {
let $ = cheerio.load(body);
let scripts = $("script[type='text/javascript']"), graphql;
try {
graphql = JSON.parse(
scripts[3].children[0].data
.replace("window._sharedData = ", "")
.replace("};", "}")
).entry_data.ProfilePage[0].graphql.user;
} catch (e) {
return reject(e)
}
return resolve({
"profileLink": "https://www.instagram.com/".concat(graphql.username),
"subscriberCount": graphql.edge_followed_by.count,
"subscribtions": graphql.edge_follow.count,
"postCount": graphql.edge_owner_to_timeline_media.count,
"username": graphql.username,
"isPrivate": graphql.is_private,
"isVerified": graphql.is_verified,
"fullName": graphql.full_name,
"bio": graphql.biography,
"id": graphql.id,
"avatar": graphql.profile_pic_url,
"avatarHD": graphql.profile_pic_url_hd,
"posts": graphql.edge_owner_to_timeline_media.edges.map(edge => {
return {
"id": edge.node.id,
"captionText": edge.node.edge_media_to_caption.edges.length === 0
? null
: edge.node.edge_media_to_caption.edges[0].node.text,
"shortcode": edge.node.shortcode,
"link": `https://www.instagram.com/p/${edge.node.shortcode}`,
"commentsCount": edge.node.edge_media_to_comment.count,
"timestamp": edge.node.taken_at_timestamp,
"likes": edge.node.edge_liked_by.count,
"location": edge.node.location || null,
"picture": {
"url": edge.node.thumbnail_src,
"thumbnail_150": edge.node.thumbnail_resources[0].src,
"thumbnail_240": edge.node.thumbnail_resources[1].src,
"thumbnail_320": edge.node.thumbnail_resources[2].src,
"thumbnail_480": edge.node.thumbnail_resources[3].src,
"thumbnail_640": edge.node.thumbnail_resources[4].src
},
"isVideo": edge.node.is_video
}
})
})
}
}
module.exports = { getData }
})
};

@@ -1,10 +0,5 @@

const scrape = require("../index")
const scrape = require("../index");
scrape("https://www.instagram.com/edouard_courty").then(result => {
console.log(result)
}).catch(e => {
console.error(e)
})
// This will log an object containing user data, and an array containing the 12 first posts of the account.
// I'll update this module and git repository when i'll have found how to get all the posts
scrape("edouard_courty")
.then(console.log)
.catch(console.error);
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