Instagram Posts to Comments Bridge avatar
Instagram Posts to Comments Bridge
Deprecated
View all Actors
This Actor is deprecated

This Actor is unavailable because the developer has decided to deprecate it. Would you like to try a similar Actor instead?

See alternative Actors
Instagram Posts to Comments Bridge

Instagram Posts to Comments Bridge

lukaskrivka/instagram-posts-to-comments

This simple actor helps you to get comments from Instagram user profiles. It acts as a bridge between one run scraping posts and second one scraping comments from these posts

Dockerfile

1# First, specify the base Docker image. You can read more about
2# the available images at https://sdk.apify.com/docs/guides/docker-images
3# You can also use any other image from Docker Hub.
4FROM apify/actor-node:16
5
6# Second, copy just package.json and package-lock.json since those are the only
7# files that affect "npm install" in the next step, to speed up the build.
8COPY package*.json ./
9
10# Install NPM packages, skip optional and development dependencies to
11# keep the image small. Avoid logging too much and print the dependency
12# tree for debugging
13RUN npm --quiet set progress=false \
14 && npm install --only=prod --no-optional \
15 && echo "Installed NPM packages:" \
16 && (npm list || true) \
17 && echo "Node.js version:" \
18 && node --version \
19 && echo "NPM version:" \
20 && npm --version
21
22# Next, copy the remaining files and directories with the source code.
23# Since we do this after NPM install, quick build will be really fast
24# for most source file changes.
25COPY . ./
26
27# Optionally, specify how to launch the source code of your actor.
28# By default, Apify's base Docker images define the CMD instruction
29# that runs the Node.js source code using the command specified
30# in the "scripts.start" section of the package.json file.
31# In short, the instruction looks something like this:
32#
33# CMD npm start

main.js

1const Apify = require('apify');
2
3const { log } = Apify.utils;
4
5Apify.main(async () => {
6    let {
7        datasetId,
8        resource,
9        taskIdOrName
10    } = await Apify.getInput();
11    if (!datasetId && resource) {
12        datasetId = resource.defaultDatasetId;
13    }
14
15    log.info(`Loading dataset: ${datasetId}`)
16
17    const dataset = await Apify.openDataset(datasetId);
18    const { items } = await dataset.getData({
19        clean: true,
20        fields: ['url']
21    });
22
23    log.info(`Loaded ${items.length} URLs from the dataset`);
24
25    const directUrls = items.map((item) => item.url);
26
27    log.info(`Calling actor to scrape posts`);
28
29    let run;
30    // User can provide task to call, otherwise we call actor directly
31    if (taskIdOrName) {
32        run = await Apify.callTask(
33            taskIdOrName,
34            { directUrls, resultsType: 'comments'},
35            { waitSecs: 0 }
36        )
37    } else {
38        const actorInput = {
39            directUrls,
40            resultsType: 'comments',
41            "proxy": {
42                "useApifyProxy": true,
43                "apifyProxyGroups": [
44                "RESIDENTIAL"
45                ]
46            },
47            "resultsLimit": 1000,
48        }
49        run = await Apify.call(
50            'jaroslavhejlek/instagram-scraper',
51            actorInput,
52             { waitSecs: 0 }
53        )
54    }
55
56    log.info(`Started run to scrape posts with ID: ${run.id}`);
57    log.info(`You can view the run here:`);
58    log.info(`https://my.apify.com/actors/shu8hvrXbJbY3Eb9W#/runs/${run.id}`)
59
60});

package.json

1{
2    "name": "my-actor",
3    "version": "0.0.1",
4    "dependencies": {
5        "apify": "^1.2.1"
6    },
7    "scripts": {
8        "start": "node main.js"
9    },
10    "author": "Me!"
11}
Developer
Maintained by Community