Skip to content

Instantly share code, notes, and snippets.

@gippy
Last active December 5, 2018 15:05
Show Gist options
  • Save gippy/90f51ae34c1559a3d530e7ba469983f5 to your computer and use it in GitHub Desktop.
Save gippy/90f51ae34c1559a3d530e7ba469983f5 to your computer and use it in GitHub Desktop.
Test of Actor input schema

README

This is readme...

# Image is based on Node.js 8.X
FROM node:8-alpine
LABEL maintainer="[email protected]" Description="Image is used to run basic Apify acts"
# Remove yarn, it's not needed
RUN rm -rf /opt/yarn /usr/local/bin/yarn /usr/local/bin/yarnpkg
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Copy source code
COPY package.json main.js /usr/src/app/
# Install default dependencies, print versions of everything
RUN npm --quiet set progress=false \
&& npm install --only=prod --no-optional \
&& echo "Installed NPM packages:" \
&& npm list \
&& echo "Node.js version:" \
&& node --version \
&& echo "NPM version:" \
&& npm --version
# Tell Node.js this is a production environemnt
ENV NODE_ENV=production
# Enable Node.js process to use a lot of memory
ENV NODE_OPTIONS="--max_old_space_size=16000"
# Not using "npm start" to avoid unnecessary process, using CMD to enable simple overriding
CMD [ "node", "main.js" ]
{
"title": "Input schema test",
"type": "object",
"schemaVersion": 1,
"properties": {
"startUrls": {
"title": "Start URLs",
"type": "array",
"description": "URLs to start with",
"default": [
{ "url": "http://example.com" }
],
"editor": "requestListSources"
},
"startUrls2": {
"title": "Start URLs",
"type": "array",
"description": "URLs to start with",
"prefill": [
{ "url": "http://example.com" }
],
"editor": "requestListSources"
},
"proxy": {
"title": "Proxy configuration",
"type": "object",
"description": "Proxy configuration",
"default": { "useApifyProxy": false },
"editor": "proxy"
},
"pageFunction": {
"title": "Page function",
"type": "string",
"description": "Function executed for each request",
"default": "async () => {\n return $('title').text();\n\n}",
"editor": "javascript"
},
"textfieldProp": {
"title": "Some text field",
"type": "string",
"description": "Xxx",
"default": "blaah blaah",
"editor": "textfield"
},
"textfieldProp2": {
"title": "Some text field with prefill",
"type": "string",
"description": "Xxx",
"prefill": "tohle je prefill",
"editor": "textfield"
},
"textareaProp": {
"title": "Some text area",
"type": "string",
"description": "Yyy",
"default": "blaah\nblaah\nblaah",
"editor": "textarea"
},
"useRequestQueue": {
"title": "Use request queue",
"type": "boolean",
"description": "Request queue enables recursive crawling",
"default": false,
"groupCaption": "Options",
"groupDescription": "Various crawler settings"
},
"verboseLog": {
"title": "Verbose log",
"type": "boolean",
"description": "Debug messages will be included in the log.",
"default": true
},
"disableWebSecurity": {
"title": "Disable web security?",
"type": "boolean",
"description": "Crawler will ignore SSL certificate errors.",
"default": false
},
"enumPropTitles": {
"title": "Country",
"type": "string",
"description": "Select country",
"default": "us",
"enum": ["us", "fr", "de"],
"enumTitles": ["USA", "France", "Germany"]
},
"enumProp": {
"title": "Country",
"type": "string",
"description": "Select country",
"default": "us",
"enum": ["us", "fr", "de"]
},
"maxPagesPerCrawl": {
"title": "Miximum pages per crawl",
"type": "integer",
"description": "Maximum number of pages that the crawler will open.",
"minimum": 1,
"maximum": 20,
"default": 2,
"unit": "Pages"
},
"pseudoUrls": {
"title": "Pseudo-URLs",
"type": "array",
"description": "Pseudo-URLs matching requests you want to enqueue",
"editor": "json"
}
},
"required": ["startUrls", "pageFunction", "maxPagesPerCrawl"]
}
// This file will be replaced by the content of the Act2.sourceCode field,
// we keep this one here just for testing and clarification.
console.log('Testing node-basic image...');
const Apify = require('apify');
Apify.main(async () => {
console.log('Starting...\n\n');
console.log(await Apify.getValue('INPUT'));
console.log('\n\nDone!');
});
{
"description": "Anonymous act on the Apify Actor platform",
"version": "0.0.1",
"license": "UNLICENSED",
"main": "main.js",
"scripts": {
"start": "node main.js"
},
"dependencies": {
"apify": ">=0.5.38",
"apify-client": ">=0.2.9"
},
"repository": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment