Comments (7)
Thank you, mind you one last question, if i want to use only 1 shortcode (the last one) how can i do that? I only need the recent one to compare if it's a new post.
nvm, new Array(data[0].node.shortcode)
is the answer! Excellent! Thank you.
from instamancer.
This isn't part of Instamancer's core functionality, but you can write something to do it yourself with Instamancer. There may be other instagram tools that do what you're after, but I'm not aware of any.
For a user this is difficult, because Instamancer doesn't retrieve all of a user's most recent posts unless it's in full mode, and posts are returned out of order in full mode. Also, it's kinda wasteful because it would require you to create and destroy a new browser instance each time you want to check for new posts.
Instead, I'd just do this in a loop every x seconds:
- Make an http request to the user's page on instagram with some http library
- Parse the data in the line that starts with:
<script type="text/javascript">window._sharedData =
- Look for new post ids
- Use
Instamancer.post(ids, options)
to get the data for new posts
from instamancer.
Thank you for your idea, it's awesome. I'm trying to use your library but im getting this:
const Instamancer = require('instamancer');
async function getDataInstagrambyID() {
let data = await instagramPhotos();
console.log(Instamancer.post(data[0].node.id))
}
getDataInstagrambyID();
console:
Object [AsyncGenerator] {}
I didn't install Instamancer globally because i don't need it. I just did npm i instamancer --save-dev
Thank you.
EDIT: As you can see, i'm recently learning about coding. I read a little further testing but i'm not sure what type of id
should i use. shortcode
or id
? I learned that i have use .next();
in order to the function starts. But if i use id
as '2099751656438958566'
or shortcode
as B0j0QGulQnm
with id using headless: false
i get /p/undefined
if i use shortcode i get /p/B/
like it's using the first letter only. Could be i'm doing something wrong?
EDIT2: Using silent: false
im getting in the console:
B Total: 5 State: Scraping Sleeping: 1 Scraped: 0
0 Total: 5 State: Scraping Sleeping: 1 Scraped: 0
j Total: 5 State: Scraping Sleeping: 1 Scraped: 0
...
Like doing letter by letter and not the whole shortcode. I've installed as -g
aswell and using the command-line instamancer post [ids]
it works, so im clueless, any help would be appreciate it.
npm -v: 6.9.0
node -v: 12.6.0
from instamancer.
post(ids, options)
takes an array of posts, your issue with it only accessing /p/B
is because you're only passing it a single string.
Posts on Instagram have a field called id
but it can't be used to retrieve posts, so we use the shortcode as the identifier.
Don't worry about global install, that's for the CLI tool.
Adapting your code, it'd look something like this:
const Instamancer = require('instamancer');
async function getDataInstagrambyID() {
const data = await instagramPhotos();
const posts = Instamancer.post(data.map(post => post.node.shortcode));
for await (const post of posts) {
console.log(post);
}
}
getDataInstagrambyID();
from instamancer.
I'm closing this as resolved, sorry for wasting your time on this. It's working now with your code. Thank you very much, have a nice day. I need much to learn.
from instamancer.
Great! Don't worry about wasting my time, I'm happy to help.
from instamancer.
And if you're a new developer, you might find using something like Instaloader or Instalooter to be a bit easier to wrap your head around when you're writing this because there's less async/await involved
from instamancer.
Related Issues (20)
- [FEATURE] Need a step-by-step example HOT 2
- [BUG] Cannot use tagged
- [BUG] HOT 1
- [BUG] After scraping around 800 hashtags Instamancer reloads the browser HOT 6
- Instgram login pops up and scraping freezes [BUG - possibly...?] HOT 1
- [FEATURE] Serverless Framework Support HOT 2
- Omitting fullAPI skips first 12 posts HOT 2
- [BUG] Redirecting to Instagram login page HOT 8
- Alert from # used in post. HOT 4
- Scraped: 0 in production server HOT 3
- [BUG] Scraping is not working anymore because Instagram requres authorization HOT 9
- [FEATURE] Parallel Batch Processing? HOT 1
- [BUG] Basic API does not work HOT 1
- [BUG] HOT 1
- I'm not getting the latest posts HOT 2
- Get amount of certain hashtag[FEATURE] HOT 1
- [FEATURE] Want to add new attribute under Owner HOT 1
- Is it possible to download only the first slide from post that have multiple? HOT 1
- Write to data file on the fly? HOT 2
- [BUG] Instagram requires login HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from instamancer.