AgentQL Demo
Try for free
No credit card required
Go to Store
AgentQL Demo
mnmkng/agentql-demo
Try for free
No credit card required
This Actor wraps the AgentQL API to showcase its monetization on Apify.
Developer
Maintained by Community
Actor Metrics
1 monthly user
No reviews yet
No bookmarks yet
>99% runs succeeded
Created in Mar 2025
Modified 2 days ago
Categories
.actor/Dockerfile
1# Specify the base Docker image. You can read more about
2# the available images at https://docs.apify.com/sdk/js/docs/guides/docker-images
3# You can also use any other image from Docker Hub.
4FROM apify/actor-node:20
5
6# Check preinstalled packages
7RUN npm ls crawlee apify puppeteer playwright
8
9# Copy just package.json and package-lock.json
10# to speed up the build using Docker layer cache.
11COPY package*.json ./
12
13# Install NPM packages, skip optional and development dependencies to
14# keep the image small. Avoid logging too much and print the dependency
15# tree for debugging
16RUN npm --quiet set progress=false \
17 && npm install --omit=dev --omit=optional \
18 && echo "Installed NPM packages:" \
19 && (npm list --omit=dev --all || true) \
20 && echo "Node.js version:" \
21 && node --version \
22 && echo "NPM version:" \
23 && npm --version \
24 && rm -r ~/.npm
25
26# Next, copy the remaining files and directories with the source code.
27# Since we do this after NPM install, quick build will be really fast
28# for most source file changes.
29COPY . ./
30
31# Create and run as a non-root user.
32RUN adduser -h /home/apify -D apify && \
33 chown -R apify:apify ./
34USER apify
35
36# Run the image.
37CMD npm start --silent
.actor/actor.json
1{
2 "actorSpecification": 1,
3 "name": "my-actor-6",
4 "title": "Scrape single page in JavaScript",
5 "description": "Scrape data from single page with provided URL.",
6 "version": "0.0",
7 "meta": {
8 "templateId": "js-start"
9 },
10 "input": "./input_schema.json",
11 "dockerfile": "./Dockerfile"
12}
.actor/input_schema.json
1{
2 "title": "Scrape data from a web page using AgentQL",
3 "type": "object",
4 "schemaVersion": 1,
5 "properties": {
6 "url": {
7 "title": "URL of the page",
8 "type": "string",
9 "description": "The URL of website you want to get the data from.",
10 "editor": "textfield",
11 "prefill": "https://news.ycombinator.com/"
12 }
13 },
14 "required": ["url"]
15}
src/main.js
1import { Actor } from 'apify';
2// this is ESM project, and as such, it requires you to specify extensions in your relative imports
3// read more about this here: https://nodejs.org/docs/latest-v18.x/api/esm.html#mandatory-file-extensions
4// import { router } from './routes.js';
5
6// The init() call configures the Actor for its environment. It's recommended to start every Actor with an init().
7await Actor.init();
8
9// Structure of input is defined in input_schema.json
10const input = await Actor.getInput();
11const { url } = input;
12
13// Fetch the HTML content of the page.
14const response = await fetch('https://api.agentql.com/v1/query-data', {
15 method: 'POST',
16 headers: {
17 'X-API-Key': process.env.AGENTQL_API_KEY,
18 'Content-Type': 'application/json'
19 },
20 body: JSON.stringify({
21 query: "{ articles[] { title upvotes } }",
22 url,
23 params: {
24 wait_for: 0,
25 is_scroll_to_bottom_enabled: false,
26 mode: "fast",
27 is_screenshot_enabled: false
28 }
29 })
30});
31const data = await response.json();
32
33// Save headings to Dataset - a table-like storage.
34await Actor.pushData(data);
35
36// Gracefully exit the Actor process. It's recommended to quit all Actors with an exit().
37await Actor.exit();
.dockerignore
1# configurations
2.idea
3
4# crawlee and apify storage folders
5apify_storage
6crawlee_storage
7storage
8
9# installed files
10node_modules
11
12# git folder
13.git
.gitignore
1# This file tells Git which files shouldn't be added to source control
2.DS_Store
3.idea
4dist
5node_modules
6apify_storage
7storage/*
8!storage/key_value_stores
9storage/key_value_stores/*
10!storage/key_value_stores/default
11storage/key_value_stores/default/*
12!storage/key_value_stores/default/INPUT.json
package.json
1{
2 "name": "js-scrape-single-page",
3 "version": "0.0.1",
4 "type": "module",
5 "description": "This is an example of an Apify actor.",
6 "engines": {
7 "node": ">=18.0.0"
8 },
9 "dependencies": {
10 "apify": "^3.2.6",
11 "axios": "^1.5.0",
12 "cheerio": "^1.0.0-rc.12"
13 },
14 "scripts": {
15 "start": "node ./src/main.js",
16 "test": "echo \"Error: oops, the actor has no tests yet, sad!\" && exit 1"
17 },
18 "author": "It's not you it's me",
19 "license": "ISC"
20}