Comments (9)
Ok Sir. Thank you. I will try it.
from instamancer.
Are you trying to use the instamancer package in the browser, or with an server that the browser connects to?
from instamancer.
I am using the instamancer package in a server that the browser connects to. It is an angular app created with NG create.
from instamancer.
https://github.com/bwyyoung/DMSolutions_MEAN
Here is the project with the source code I developed so far. It seems instamancer does not play well with angular.
from instamancer.
I'm not really familiar with Angular and can't get your example running without setting up mongo etc. but isn't this running instamancer in the browser?
from instamancer.
Yes, I think so. Sorry. I am a beginner at both Instamancer and Angular, and maybe you have ideas on how best to run this.
from instamancer.
Well again, I'm not really familiar with angular so I can't tell you how it works best in that ecosystem.
Basically, instamancer needs to run an instance of chrome in order to work, which means it has to run on a server, not in a browser with webpack like it appears to be in your example. For most packages this isn't the case, however most if not all instagram api packages can't be run in a browser because of how restricted browsers are when making http requests.
To run it on a server you need to set up express or something like it, and then the browser can communicate with AJAX. The server will run instamancer and send the results to the browser.
from instamancer.
Thank you sir for responding so quickly and frequently.
Ok. I already have Express and Node setup on server side. Would you have an example of how to run Instamancer on server side with express?
from instamancer.
Here's a quick example:
const express = require('express')
const app = express()
const port = 3000
const instamancer = require('instamancer')
async function getPosts(tag) {
const hashtag = instamancer.hashtag(tag, {total: 5, silent: true});
const posts = [];
for await (const post of hashtag) {
posts.push(post);
}
return posts;
}
let cachedPosts = []
async function getCached() {
cachedPosts = await getPosts("puppies");
}
setTimeout(getCached, 3000)
app.get('/cached', async (req, res) => {
res.send(JSON.stringify(cachedPosts));
})
app.get('/live', async (req, res) => {
const posts = await getPosts(req.params["tag"]);
res.send(JSON.stringify(posts));
})
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
Visiting localhost:3000/cached
will return a list of posts that's updated once every 5 minutes, and visiting localhost:3000/live?tag=your_tag_here
will fetch them on-demand.
You have to wait 30-seconds to a minute for the cached posts to appear, and you'll have to wait about as long for something to be returned on the live endpoint. That should get you started.
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.