Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
add get profile picture url and exmpale folder
Browse files Browse the repository at this point in the history
  • Loading branch information
khaledalam committed Sep 23, 2020
1 parent b3d1e3a commit 46a017e
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 4 deletions.
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

NodeJS module NPM package that helps to scrape and load instagram profile media and useful information.

## Used by 5 <img src="https://mpng.subpng.com/20180330/avw/kisspng-computer-icons-person-clip-art-name-5abea9694a6aa0.8829806515224446493048.jpg" width="20">
Repositories that depend on <a href="https://github.com/khaledalam/instagrammer">instagrammer</a>
## 5 <img src="https://mpng.subpng.com/20180330/avw/kisspng-computer-icons-person-clip-art-name-5abea9694a6aa0.8829806515224446493048.jpg" width="15"> Repositories that depend on <a href="https://github.com/khaledalam/instagrammer">instagrammer</a>
- [shidoitsuka / homies](https://github.com/shidoitsuka/homies)
- [gabszzz / zork](https://github.com/gabszzz/zork)
- [Horsgle / API-Scrap-Instagram](https://github.com/Horsgle/API-Scrap-Instagram)
Expand All @@ -36,6 +35,26 @@ Instagram has gone to great lengths to prevent scraping and other unauthorized a
<br>


### Profile Picture Url:

```
const instagrammer = require("instagrammer");
const username = 'instagram';
instagrammer.profilePicture(username).then(res => console.log(JSON.stringify(res)));
```

<details><summary>Example output response</summary><p>

```json
{
"https://scontent-hbe1-1.cdninstagram.com/v/t51.2885-19/s150x150/119381356_363756831450146_3008355575418576013_n.jpg?_nc_ht=scontent-hbe1-1.cdninstagram.com&_nc_ohc=BMpoCdJah2YAX-S235E&oh=a3b3c783b0e08cacd9c93cd1ce68a42e&oe=5F939876"
}
```
</p></details>

<br><hr><br>

### Recent Profile Posts:

```
Expand Down
14 changes: 14 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "example",
"version": "1.0.0",
"description": "",
"main": "profile_picture.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"instagrammer": "^1.0.11"
}
}
4 changes: 4 additions & 0 deletions example/profile_picture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const instagrammer = require("instagrammer");
const username = 'instagram';

instagrammer.profilePicture(username).then(res => console.log(JSON.stringify(res)));
23 changes: 22 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,27 @@ const getIGUrl = (username = username) => 'https://www.instagram.com/' + usernam
const getPOSTUrl = (postId = postId) => 'https://www.instagram.com/p/' + postId + '/?__a=1';
const errorMessage = 'Cannot detect option';


/**
* Scrape instagram profile picture url.
* @since 1.0.11
* @access public
*
* @param {string} username Instagram profile username.
*/
const profilePicture = async(username = username) => {

try {
const response = await axios.get(getIGUrl(username));

return response.data.graphql.user.profile_pic_url || errorMessage;

} catch (error) {
console.error('instagrammer_profile_picture', error);
return error;
}
}

/**
* Scrape instagram profile media and more useful information.
* @since 1.0.0
Expand Down Expand Up @@ -173,7 +194,6 @@ const takenTimestamp = async(postId = postId) => {




module.exports = {
profile,
postComments,
Expand All @@ -183,4 +203,5 @@ module.exports = {
isCaptionEdited,
isCommentsDisabled,
takenTimestamp,
profilePicture
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "instagrammer",
"version": "1.0.10",
"version": "1.0.11",
"description": "NodeJS module NPM package that helps to scrap and load instagram profile media, posts comments and more useful information.",
"main": "index.js",
"author": {
Expand Down

0 comments on commit 46a017e

Please sign in to comment.