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

instagram-tags-post

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

instagram-tags-post - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

68

index.js

@@ -6,3 +6,3 @@ #!/usr/bin/env node

if(argv.h||argv._.length ===0){
if (argv.h || argv._.length === 0) {
console.log('example command: tagsaver tagName --proxy=http://127.0.0.1:1080')

@@ -20,7 +20,7 @@ process.exit(0)

const fetchData = async function(tag){
const fetchData = async function (tag) {
const options = {
url:`https://www.instagram.com/explore/tags/${tag}/?__a=1`,
url: `https://www.instagram.com/explore/tags/${tag}/?__a=1`,
}
if(argv.proxy){
if (argv.proxy) {
options.proxy = argv.proxy

@@ -32,18 +32,18 @@ }

const getNextPage = async (end_cursor)=>{
let variables=JSON.stringify({
tag_name:tag,
first:12,
after:end_cursor
const getNextPage = async (end_cursor) => {
let variables = JSON.stringify({
tag_name: tag,
first: 12,
after: end_cursor
})
options.url=`https://www.instagram.com/graphql/query/?query_hash=9b498c08113f1e09617a1703c22b2f32&variables=${encodeURI(variables)}`
options.url = `https://www.instagram.com/graphql/query/?query_hash=9b498c08113f1e09617a1703c22b2f32&variables=${encodeURI(variables)}`
const res = await request(options)
return {
edges:res.data.hashtag.edge_hashtag_to_media.edges,
page_info:res.data.hashtag.edge_hashtag_to_media.page_info
edges: res.data.hashtag.edge_hashtag_to_media.edges,
page_info: res.data.hashtag.edge_hashtag_to_media.page_info
}
}
const getOwner = async(shortcode)=>{
options.url=`https://www.instagram.com/p/${shortcode}/?__a=1`
const getOwner = async (shortcode) => {
options.url = `https://www.instagram.com/p/${shortcode}/?__a=1`
const owner = await request(options)

@@ -54,7 +54,7 @@ return owner.graphql.shortcode_media.owner

let edges = data.graphql.hashtag.edge_hashtag_to_media.edges
for(const k of edges){
for (const k of edges) {
await waitSeocond(.5)
k.node.owner = await getOwner(k.node.shortcode)
k.node.owner = await getOwner(k.node.shortcode)
}
while(hasNext){
while (hasNext) {
await waitSeocond(2)

@@ -64,23 +64,27 @@ let list = await getNextPage(end_cursor)

end_cursor = list.page_info.end_cursor
for(const k of list.edges){
for (const k of list.edges) {
await waitSeocond(.5)
k.node.owner = await getOwner(k.node.shortcode)
k.node.owner = await getOwner(k.node.shortcode)
}
edges = edges.concat(list.edges)
console.log('current data rows: ',edges.length)
console.log('current data rows: ', edges.length)
}
save2json(edges,tag)
save2json(edges, tag)
}
const save2json = (data,name)=>{
try {
const cwd = require('process').cwd()
const path = require('path').join(cwd,`./${name}.json`)
require('fs').writeFileSync(path,JSON.stringify(data))
} catch (error) {
console.log(error)
process.exit(1)
}
const save2json = (data, name) => {
const cwd = require('process').cwd()
const path = require('path').join(cwd, `./${name}.json`)
require('fs').writeFile(path, JSON.stringify(data), 'utf8',
(error) => {
if(error){
console.log(error)
process.exit(1)
} else {
console.log(`all post fetched down(${name}.json),pleas see your current work directory`)
process.exit(0)
}
})
}
console.log('tag which your inputed: ',argv._[0])
console.log('your proxy: ',argv.proxy?argv.proxy:'null')
console.log('tag which your inputed: ', argv._[0])
console.log('your proxy: ', argv.proxy ? argv.proxy : 'null')
fetchData(argv._[0])
{
"name": "instagram-tags-post",
"version": "1.0.2",
"version": "1.0.3",
"description": "get instagram post by tags",

@@ -5,0 +5,0 @@ "main": "index.js",

# instagram-tags-post
get instagram post by tags
> get instagram post by tags
> `npm i instagram-tags-post -g`
you must install global.
example: tagsaver tagName --proxy=http://127.0.0.1:1080
> the file will saved as json on your current work directory
# data
the file will saved as json on your current work directory
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