Stable Diffusion Scraper avatar
Stable Diffusion Scraper

Deprecated

Pricing

Pay per usage

Go to Store
Stable Diffusion Scraper

Stable Diffusion Scraper

Deprecated

Developed by

oelin

oelin

Maintained by Community

Get instant access to Stable Diffusion and hundreds of other generative AI models hosted on Replicate.

0.0 (0)

Pricing

Pay per usage

1

Total users

12

Monthly users

1

Runs succeeded

0%

Last modified

2 years ago

.actor/Dockerfile

# Specify the base Docker image. You can read more about
# the available images at https://docs.apify.com/sdk/js/docs/guides/docker-images
# You can also use any other image from Docker Hub.
FROM apify/actor-node:18
# Copy just package.json and package-lock.json
# to speed up the build using Docker layer cache.
COPY package*.json ./
# Install NPM packages, skip optional and development dependencies to
# keep the image small. Avoid logging too much and print the dependency
# tree for debugging
RUN npm --quiet set progress=false \
&& npm install --omit=dev --omit=optional \
&& echo "Installed NPM packages:" \
&& (npm list --omit=dev --all || true) \
&& echo "Node.js version:" \
&& node --version \
&& echo "NPM version:" \
&& npm --version \
&& rm -r ~/.npm
# Next, copy the remaining files and directories with the source code.
# Since we do this after NPM install, quick build will be really fast
# for most source file changes.
COPY . ./
# Run the image.
CMD npm start --silent

.actor/actor.json

{
"actorSpecification": 1,
"name": "my-actor",
"title": "Scrape single page in JavaScript",
"description": "Scrape data from single page with provided URL.",
"version": "0.0",
"meta": {
"templateId": "js-start"
},
"input": "./input_schema.json",
"dockerfile": "./Dockerfile"
}

.actor/input_schema.json

{
"title": "Get instant access to Stable Diffusion and hundres of other generative AI models hosted on Replicate.",
"type": "object",
"schemaVersion": 1,
"properties": {
"prompt": {
"title": "Prompt",
"type": "string",
"description": "What to create ✨",
"editor": "textfield",
"prefill": "an astronaut riding on a horse"
},
"model": {
"title": "Model",
"type": "string",
"description": "Which model to use.",
"editor": "textfield",
"prefill": "ai-forever/kandinsky-2.2:ea1addaab376f4dc227f5368bbd8eff901820fd1cc14ed8cad63b29249e9d463"
},
"options": {
"title": "Options",
"type": "object",
"description": "Which options to use.",
"editor": "json",
"prefill": {
"width": 1024,
"height": 1024
}
}
},
"required": ["prompt", "model"]
}

src/main.js

1import { Actor } from "apify";
2
3import replicate from "node-replicate";
4
5// this is ESM project, and as such, it requires you to specify extensions in your relative imports
6// read more about this here: https://nodejs.org/docs/latest-v18.x/api/esm.html#mandatory-file-extensions
7// import { router } from './routes.js';
8
9// The init() call configures the Actor for its environment. It's recommended to start every Actor with an init().
10await Actor.init();
11
12// Structure of input is defined in input_schema.json
13const input = await Actor.getInput();
14const { prompt, model, options } = input
15
16const response = await replicate.run(model, { prompt, ...options })
17
18console.log(response)
19
20// Save headings to Dataset - a table-like storage.
21await Actor.pushData({ response: JSON.parse(JSON.stringify(response)) });
22
23// Gracefully exit the Actor process. It's recommended to quit all Actors with an exit().
24await Actor.exit();

.dockerignore

# configurations
.idea
# crawlee and apify storage folders
apify_storage
crawlee_storage
storage
# installed files
node_modules
# git folder
.git

.gitignore

# This file tells Git which files shouldn't be added to source control
.DS_Store
.idea
dist
node_modules
apify_storage
storage/*
!storage/key_value_stores
storage/key_value_stores/*
!storage/key_value_stores/default
storage/key_value_stores/default/*
!storage/key_value_stores/default/INPUT.json

package.json

{
"name": "js-scrape-single-page",
"version": "0.0.1",
"type": "module",
"description": "This is an example of an Apify actor.",
"engines": {
"node": ">=18.0.0"
},
"dependencies": {
"apify": "^3.0.0",
"axios": "^1.4.0",
"cheerio": "^1.0.0-rc.12",
"node-replicate": "^2.0.0"
},
"scripts": {
"start": "node ./src/main.js",
"test": "echo \"Error: oops, the actor has no tests yet, sad!\" && exit 1"
},
"author": "It's not you it's me",
"license": "ISC"
}