@crawlee/templates 3.0.4-beta.6 → 3.0.4-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/manifest.json +14 -6
- package/package.json +1 -1
- package/templates/cheerio-js/.dockerignore +10 -0
- package/templates/cheerio-js/Dockerfile +20 -6
- package/templates/cheerio-js/package.json +0 -1
- package/templates/cheerio-js/src/routes.js +10 -10
- package/templates/cheerio-ts/.dockerignore +10 -0
- package/templates/cheerio-ts/Dockerfile +32 -14
- package/templates/cheerio-ts/src/routes.ts +11 -11
- package/templates/getting-started-js/.dockerignore +10 -0
- package/templates/getting-started-js/Dockerfile +29 -0
- package/templates/getting-started-js/README.md +9 -0
- package/templates/getting-started-js/package.json +16 -0
- package/templates/getting-started-js/src/main.js +24 -0
- package/templates/getting-started-ts/.dockerignore +10 -0
- package/templates/getting-started-ts/Dockerfile +51 -0
- package/templates/getting-started-ts/README.md +9 -0
- package/templates/getting-started-ts/package.json +24 -0
- package/templates/getting-started-ts/src/main.ts +24 -0
- package/templates/getting-started-ts/tsconfig.json +13 -0
- package/templates/playwright-js/.dockerignore +10 -0
- package/templates/playwright-js/Dockerfile +20 -6
- package/templates/playwright-js/README.md +0 -18
- package/templates/playwright-js/package.json +0 -1
- package/templates/playwright-js/src/routes.js +10 -10
- package/templates/playwright-ts/.dockerignore +10 -0
- package/templates/playwright-ts/Dockerfile +35 -16
- package/templates/playwright-ts/README.md +0 -18
- package/templates/playwright-ts/src/routes.ts +10 -10
- package/templates/puppeteer-js/.dockerignore +10 -0
- package/templates/puppeteer-js/Dockerfile +20 -6
- package/templates/puppeteer-js/README.md +0 -18
- package/templates/puppeteer-js/package.json +0 -1
- package/templates/puppeteer-js/src/routes.js +10 -10
- package/templates/puppeteer-ts/.dockerignore +10 -0
- package/templates/puppeteer-ts/Dockerfile +35 -16
- package/templates/puppeteer-ts/README.md +0 -18
- package/templates/puppeteer-ts/src/routes.ts +10 -10
package/manifest.json
CHANGED
|
@@ -1,28 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"templates": [
|
|
3
|
+
{
|
|
4
|
+
"name": "getting-started-ts",
|
|
5
|
+
"description": "Getting started example [TypeScript]"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"name": "getting-started-js",
|
|
9
|
+
"description": "Getting started example [JavaScript]"
|
|
10
|
+
},
|
|
3
11
|
{
|
|
4
12
|
"name": "cheerio-ts",
|
|
5
|
-
"description": "
|
|
13
|
+
"description": "CheerioCrawler template project [TypeScript]"
|
|
6
14
|
},
|
|
7
15
|
{
|
|
8
16
|
"name": "playwright-ts",
|
|
9
|
-
"description": "
|
|
17
|
+
"description": "PlaywrightCrawler template project [TypeScript]"
|
|
10
18
|
},
|
|
11
19
|
{
|
|
12
20
|
"name": "puppeteer-ts",
|
|
13
|
-
"description": "
|
|
21
|
+
"description": "PuppeteerCrawler template project [TypeScript]"
|
|
14
22
|
},
|
|
15
23
|
{
|
|
16
24
|
"name": "cheerio-js",
|
|
17
|
-
"description": "
|
|
25
|
+
"description": "CheerioCrawler template project [JavaScript]"
|
|
18
26
|
},
|
|
19
27
|
{
|
|
20
28
|
"name": "playwright-js",
|
|
21
|
-
"description": "
|
|
29
|
+
"description": "PlaywrightCrawler template project [JavaScript]"
|
|
22
30
|
},
|
|
23
31
|
{
|
|
24
32
|
"name": "puppeteer-js",
|
|
25
|
-
"description": "
|
|
33
|
+
"description": "PlaywrightCrawler template project [JavaScript]"
|
|
26
34
|
}
|
|
27
35
|
]
|
|
28
36
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
|
+
# Specify the base Docker image. You can read more about
|
|
2
|
+
# the available images at https://crawlee.dev/docs/guides/docker-images
|
|
3
|
+
# You can also use any other image from Docker Hub.
|
|
1
4
|
FROM apify/actor-node:16
|
|
2
5
|
|
|
3
|
-
#
|
|
4
|
-
|
|
5
|
-
COPY
|
|
6
|
+
# Copy just package.json and package-lock.json
|
|
7
|
+
# to speed up the build using Docker layer cache.
|
|
8
|
+
COPY package*.json ./
|
|
6
9
|
|
|
7
|
-
#
|
|
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
|
|
8
13
|
RUN npm --quiet set progress=false \
|
|
9
|
-
&& npm install --
|
|
14
|
+
&& npm install --omit=dev --omit=optional \
|
|
10
15
|
&& echo "Installed NPM packages:" \
|
|
11
|
-
&& (npm list --
|
|
16
|
+
&& (npm list --omit=dev --all || true) \
|
|
12
17
|
&& echo "Node.js version:" \
|
|
13
18
|
&& node --version \
|
|
14
19
|
&& echo "NPM version:" \
|
|
15
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.
|
|
25
|
+
COPY . ./
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Run the image.
|
|
29
|
+
CMD npm start --silent
|
|
@@ -3,19 +3,19 @@ import { Dataset, createCheerioRouter } from 'crawlee';
|
|
|
3
3
|
export const router = createCheerioRouter();
|
|
4
4
|
|
|
5
5
|
router.addDefaultHandler(async ({ enqueueLinks, log }) => {
|
|
6
|
-
log.info(`
|
|
6
|
+
log.info(`enqueueing new URLs`);
|
|
7
7
|
await enqueueLinks({
|
|
8
|
-
globs: ['https://crawlee.dev
|
|
9
|
-
label: '
|
|
8
|
+
globs: ['https://crawlee.dev/*'],
|
|
9
|
+
label: 'detail',
|
|
10
10
|
});
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
router.addHandler('
|
|
14
|
-
log.info(`Handle pagination`);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
router.addHandler('DETAIL', async ({ request, $, log }) => {
|
|
13
|
+
router.addHandler('detail', async ({ request, $, log }) => {
|
|
18
14
|
const title = $('title').text();
|
|
19
|
-
log.info(
|
|
20
|
-
|
|
15
|
+
log.info(`${title}`, { url: request.loadedUrl });
|
|
16
|
+
|
|
17
|
+
await Dataset.pushData({
|
|
18
|
+
url: request.loadedUrl,
|
|
19
|
+
title,
|
|
20
|
+
});
|
|
21
21
|
});
|
|
@@ -1,32 +1,50 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Specify the base Docker image. You can read more about
|
|
2
2
|
# the available images at https://crawlee.dev/docs/guides/docker-images
|
|
3
3
|
# You can also use any other image from Docker Hub.
|
|
4
4
|
FROM apify/actor-node:16 AS builder
|
|
5
5
|
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
COPY package*.json
|
|
9
|
-
COPY src ./src
|
|
6
|
+
# Copy just package.json and package-lock.json
|
|
7
|
+
# to speed up the build using Docker layer cache.
|
|
8
|
+
COPY package*.json ./
|
|
10
9
|
|
|
11
|
-
# Install all dependencies
|
|
12
|
-
RUN npm install --include=dev
|
|
10
|
+
# Install all dependencies. Don't audit to speed up the installation.
|
|
11
|
+
RUN npm install --include=dev --audit=false
|
|
12
|
+
|
|
13
|
+
# Next, copy the source files using the user set
|
|
14
|
+
# in the base image.
|
|
15
|
+
COPY . ./
|
|
16
|
+
|
|
17
|
+
# Install all dependencies and build the project.
|
|
18
|
+
# Don't audit to speed up the installation.
|
|
19
|
+
RUN npm run build
|
|
13
20
|
|
|
14
21
|
# Create final image
|
|
15
22
|
FROM apify/actor-node:16
|
|
16
23
|
|
|
17
|
-
# Copy only
|
|
18
|
-
COPY --from=builder /usr/src/app/package.json /usr/src/app/crawlee?json ./
|
|
24
|
+
# Copy only built JS files from builder image
|
|
19
25
|
COPY --from=builder /usr/src/app/dist ./dist
|
|
20
26
|
|
|
21
|
-
#
|
|
27
|
+
# Copy just package.json and package-lock.json
|
|
28
|
+
# to speed up the build using Docker layer cache.
|
|
29
|
+
COPY package*.json ./
|
|
30
|
+
|
|
31
|
+
# Install NPM packages, skip optional and development dependencies to
|
|
32
|
+
# keep the image small. Avoid logging too much and print the dependency
|
|
33
|
+
# tree for debugging
|
|
22
34
|
RUN npm --quiet set progress=false \
|
|
23
|
-
&& npm install --
|
|
35
|
+
&& npm install --omit=dev --omit=optional \
|
|
24
36
|
&& echo "Installed NPM packages:" \
|
|
25
|
-
&& (npm list --
|
|
37
|
+
&& (npm list --omit=dev --all || true) \
|
|
26
38
|
&& echo "Node.js version:" \
|
|
27
39
|
&& node --version \
|
|
28
40
|
&& echo "NPM version:" \
|
|
29
41
|
&& npm --version
|
|
30
42
|
|
|
31
|
-
#
|
|
32
|
-
|
|
43
|
+
# Next, copy the remaining files and directories with the source code.
|
|
44
|
+
# Since we do this after NPM install, quick build will be really fast
|
|
45
|
+
# for most source file changes.
|
|
46
|
+
COPY . ./
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# Run the image.
|
|
50
|
+
CMD npm run start:prod --silent
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Dataset, createCheerioRouter } from 'crawlee';
|
|
2
2
|
|
|
3
3
|
export const router = createCheerioRouter();
|
|
4
4
|
|
|
5
5
|
router.addDefaultHandler(async ({ enqueueLinks, log }) => {
|
|
6
|
-
log.info(`
|
|
6
|
+
log.info(`enqueueing new URLs`);
|
|
7
7
|
await enqueueLinks({
|
|
8
|
-
globs: ['https://crawlee.dev
|
|
9
|
-
label: '
|
|
8
|
+
globs: ['https://crawlee.dev/*'],
|
|
9
|
+
label: 'detail',
|
|
10
10
|
});
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
router.addHandler('
|
|
14
|
-
log.info(`Handle pagination`);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
router.addHandler('DETAIL', async ({ request, $, log }) => {
|
|
13
|
+
router.addHandler('detail', async ({ request, $, log }) => {
|
|
18
14
|
const title = $('title').text();
|
|
19
|
-
log.info(
|
|
20
|
-
|
|
15
|
+
log.info(`${title}`, { url: request.loadedUrl });
|
|
16
|
+
|
|
17
|
+
await Dataset.pushData({
|
|
18
|
+
url: request.loadedUrl,
|
|
19
|
+
title,
|
|
20
|
+
});
|
|
21
21
|
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Specify the base Docker image. You can read more about
|
|
2
|
+
# the available images at https://crawlee.dev/docs/guides/docker-images
|
|
3
|
+
# You can also use any other image from Docker Hub.
|
|
4
|
+
FROM apify/actor-node-playwright-chrome:16
|
|
5
|
+
|
|
6
|
+
# Copy just package.json and package-lock.json
|
|
7
|
+
# to speed up the build using Docker layer cache.
|
|
8
|
+
COPY --chown=myuser 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
|
|
13
|
+
RUN npm --quiet set progress=false \
|
|
14
|
+
&& npm install --omit=dev --omit=optional \
|
|
15
|
+
&& echo "Installed NPM packages:" \
|
|
16
|
+
&& (npm list --omit=dev --all || 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.
|
|
25
|
+
COPY --chown=myuser . ./
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Run the image.
|
|
29
|
+
CMD npm start --silent
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Getting started with Crawlee
|
|
2
|
+
|
|
3
|
+
This example uses `PlaywrightCrawler` to recursively crawl https://crawlee.dev using the browser automation library [Playwright](https://playwright.dev).
|
|
4
|
+
|
|
5
|
+
You can find more examples and documentation at the following links:
|
|
6
|
+
|
|
7
|
+
- [Step-by-step tutorial](https://crawlee.dev/docs/introduction) for Crawlee
|
|
8
|
+
- `PlaywrightCrawler` [API documentation](https://crawlee.dev/api/playwright-crawler/class/PlaywrightCrawler)
|
|
9
|
+
- Other [examples](https://crawlee.dev/docs/examples/playwright-crawler)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "crawlee-getting-started-js",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "This is an example of a Crawlee project.",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"crawlee": "^3.0.0",
|
|
8
|
+
"playwright": "*"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"start": "node src/main.js",
|
|
12
|
+
"test": "echo \"Error: oops, the actor has no tests yet, sad!\" && exit 1"
|
|
13
|
+
},
|
|
14
|
+
"author": "It's not you it's me",
|
|
15
|
+
"license": "ISC"
|
|
16
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// For more information, see https://crawlee.dev/
|
|
2
|
+
import { PlaywrightCrawler, Dataset } from 'crawlee';
|
|
3
|
+
|
|
4
|
+
// PlaywrightCrawler crawls the web using a headless
|
|
5
|
+
// browser controlled by the Playwright library.
|
|
6
|
+
const crawler = new PlaywrightCrawler({
|
|
7
|
+
// Use the requestHandler to process each of the crawled pages.
|
|
8
|
+
async requestHandler({ request, page, enqueueLinks, log }) {
|
|
9
|
+
const title = await page.title();
|
|
10
|
+
log.info(`Title of ${request.loadedUrl} is '${title}'`);
|
|
11
|
+
|
|
12
|
+
// Save results as JSON to ./storage/datasets/default
|
|
13
|
+
await Dataset.pushData({ title, url: request.loadedUrl });
|
|
14
|
+
|
|
15
|
+
// Extract links from the current page
|
|
16
|
+
// and add them to the crawling queue.
|
|
17
|
+
await enqueueLinks();
|
|
18
|
+
},
|
|
19
|
+
// Uncomment this option to see the browser window.
|
|
20
|
+
// headless: false,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Add first URL to the queue and start the crawl.
|
|
24
|
+
await crawler.run(['https://crawlee.dev']);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Specify the base Docker image. You can read more about
|
|
2
|
+
# the available images at https://crawlee.dev/docs/guides/docker-images
|
|
3
|
+
# You can also use any other image from Docker Hub.
|
|
4
|
+
FROM apify/actor-node-playwright-chrome:16 AS builder
|
|
5
|
+
|
|
6
|
+
# Copy just package.json and package-lock.json
|
|
7
|
+
# to speed up the build using Docker layer cache.
|
|
8
|
+
COPY --chown=myuser package*.json ./
|
|
9
|
+
|
|
10
|
+
# Install all dependencies. Don't audit to speed up the installation.
|
|
11
|
+
RUN npm install --include=dev --audit=false
|
|
12
|
+
|
|
13
|
+
# Next, copy the source files using the user set
|
|
14
|
+
# in the base image.
|
|
15
|
+
COPY --chown=myuser . ./
|
|
16
|
+
|
|
17
|
+
# Install all dependencies and build the project.
|
|
18
|
+
# Don't audit to speed up the installation.
|
|
19
|
+
RUN npm run build
|
|
20
|
+
|
|
21
|
+
# Create final image
|
|
22
|
+
FROM apify/actor-node-playwright-chrome:16
|
|
23
|
+
|
|
24
|
+
# Copy only built JS files from builder image
|
|
25
|
+
COPY --from=builder --chown=myuser /home/myuser/dist ./dist
|
|
26
|
+
|
|
27
|
+
# Copy just package.json and package-lock.json
|
|
28
|
+
# to speed up the build using Docker layer cache.
|
|
29
|
+
COPY --chown=myuser package*.json ./
|
|
30
|
+
|
|
31
|
+
# Install NPM packages, skip optional and development dependencies to
|
|
32
|
+
# keep the image small. Avoid logging too much and print the dependency
|
|
33
|
+
# tree for debugging
|
|
34
|
+
RUN npm --quiet set progress=false \
|
|
35
|
+
&& npm install --omit=dev --omit=optional \
|
|
36
|
+
&& echo "Installed NPM packages:" \
|
|
37
|
+
&& (npm list --omit=dev --all || true) \
|
|
38
|
+
&& echo "Node.js version:" \
|
|
39
|
+
&& node --version \
|
|
40
|
+
&& echo "NPM version:" \
|
|
41
|
+
&& npm --version
|
|
42
|
+
|
|
43
|
+
# Next, copy the remaining files and directories with the source code.
|
|
44
|
+
# Since we do this after NPM install, quick build will be really fast
|
|
45
|
+
# for most source file changes.
|
|
46
|
+
COPY --chown=myuser . ./
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# Run the image. If you know you won't need headful browsers,
|
|
50
|
+
# you can remove the XVFB start script for a micro perf gain.
|
|
51
|
+
CMD ./start_xvfb_and_run_cmd.sh && npm run start:prod --silent
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Getting started with Crawlee
|
|
2
|
+
|
|
3
|
+
This example uses `PlaywrightCrawler` to recursively crawl https://crawlee.dev using the browser automation library [Playwright](https://playwright.dev).
|
|
4
|
+
|
|
5
|
+
You can find more examples and documentation at the following links:
|
|
6
|
+
|
|
7
|
+
- [Step-by-step tutorial](https://crawlee.dev/docs/introduction) for Crawlee
|
|
8
|
+
- `PlaywrightCrawler` [API documentation](https://crawlee.dev/api/playwright-crawler/class/PlaywrightCrawler)
|
|
9
|
+
- Other [examples](https://crawlee.dev/docs/examples/playwright-crawler)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "crawlee-getting-started-ts",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "This is an example of a Crawlee project.",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"crawlee": "^3.0.0",
|
|
8
|
+
"playwright": "*"
|
|
9
|
+
},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@apify/tsconfig": "^0.1.0",
|
|
12
|
+
"ts-node": "^10.8.0",
|
|
13
|
+
"typescript": "^4.7.4"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"start": "npm run start:dev",
|
|
17
|
+
"start:prod": "node dist/main.js",
|
|
18
|
+
"start:dev": "ts-node-esm -T src/main.ts",
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"test": "echo \"Error: oops, the actor has no tests yet, sad!\" && exit 1"
|
|
21
|
+
},
|
|
22
|
+
"author": "It's not you it's me",
|
|
23
|
+
"license": "ISC"
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// For more information, see https://crawlee.dev/
|
|
2
|
+
import { PlaywrightCrawler, Dataset } from 'crawlee';
|
|
3
|
+
|
|
4
|
+
// PlaywrightCrawler crawls the web using a headless
|
|
5
|
+
// browser controlled by the Playwright library.
|
|
6
|
+
const crawler = new PlaywrightCrawler({
|
|
7
|
+
// Use the requestHandler to process each of the crawled pages.
|
|
8
|
+
async requestHandler({ request, page, enqueueLinks, log }) {
|
|
9
|
+
const title = await page.title();
|
|
10
|
+
log.info(`Title of ${request.loadedUrl} is '${title}'`);
|
|
11
|
+
|
|
12
|
+
// Save results as JSON to ./storage/datasets/default
|
|
13
|
+
await Dataset.pushData({ title, url: request.loadedUrl });
|
|
14
|
+
|
|
15
|
+
// Extract links from the current page
|
|
16
|
+
// and add them to the crawling queue.
|
|
17
|
+
await enqueueLinks();
|
|
18
|
+
},
|
|
19
|
+
// Uncomment this option to see the browser window.
|
|
20
|
+
// headless: false,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Add first URL to the queue and start the crawl.
|
|
24
|
+
await crawler.run(['https://crawlee.dev']);
|
|
@@ -1,15 +1,29 @@
|
|
|
1
|
+
# Specify the base Docker image. You can read more about
|
|
2
|
+
# the available images at https://crawlee.dev/docs/guides/docker-images
|
|
3
|
+
# You can also use any other image from Docker Hub.
|
|
1
4
|
FROM apify/actor-node-playwright-chrome:16
|
|
2
5
|
|
|
3
|
-
#
|
|
4
|
-
|
|
5
|
-
COPY
|
|
6
|
+
# Copy just package.json and package-lock.json
|
|
7
|
+
# to speed up the build using Docker layer cache.
|
|
8
|
+
COPY --chown=myuser package*.json ./
|
|
6
9
|
|
|
7
|
-
#
|
|
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
|
|
8
13
|
RUN npm --quiet set progress=false \
|
|
9
|
-
&& npm install --
|
|
14
|
+
&& npm install --omit=dev --omit=optional \
|
|
10
15
|
&& echo "Installed NPM packages:" \
|
|
11
|
-
&& (npm list --
|
|
16
|
+
&& (npm list --omit=dev --all || true) \
|
|
12
17
|
&& echo "Node.js version:" \
|
|
13
18
|
&& node --version \
|
|
14
19
|
&& echo "NPM version:" \
|
|
15
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.
|
|
25
|
+
COPY --chown=myuser . ./
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Run the image.
|
|
29
|
+
CMD npm start --silent
|
|
@@ -6,21 +6,3 @@ If you're looking for examples or want to learn more visit:
|
|
|
6
6
|
|
|
7
7
|
- [Documentation](https://crawlee.dev/api/playwright-crawler/class/PlaywrightCrawler)
|
|
8
8
|
- [Examples](https://crawlee.dev/docs/examples/playwright-crawler)
|
|
9
|
-
|
|
10
|
-
## Writing a README
|
|
11
|
-
|
|
12
|
-
See our tutorial on [writing READMEs for your actors](https://help.apify.com/en/articles/2912548-how-to-write-great-readme-for-your-actors) if you need more inspiration.
|
|
13
|
-
|
|
14
|
-
### Table of contents
|
|
15
|
-
|
|
16
|
-
If your README requires a table of contents, use the template below and make sure to keep the `<!-- toc start -->` and `<!-- toc end -->` markers.
|
|
17
|
-
|
|
18
|
-
<!-- toc start -->
|
|
19
|
-
- Introduction
|
|
20
|
-
- Use Cases
|
|
21
|
-
- Case 1
|
|
22
|
-
- Case 2
|
|
23
|
-
- Input
|
|
24
|
-
- Output
|
|
25
|
-
- Miscellaneous
|
|
26
|
-
<!-- toc end -->
|
|
@@ -3,19 +3,19 @@ import { Dataset, createPlaywrightRouter } from 'crawlee';
|
|
|
3
3
|
export const router = createPlaywrightRouter();
|
|
4
4
|
|
|
5
5
|
router.addDefaultHandler(async ({ enqueueLinks, log }) => {
|
|
6
|
-
log.info(`
|
|
6
|
+
log.info(`enqueueing new URLs`);
|
|
7
7
|
await enqueueLinks({
|
|
8
|
-
globs: ['https://crawlee.dev
|
|
9
|
-
label: '
|
|
8
|
+
globs: ['https://crawlee.dev/*'],
|
|
9
|
+
label: 'detail',
|
|
10
10
|
});
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
router.addHandler('
|
|
14
|
-
log.info(`Handle pagination`);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
router.addHandler('handleDetail', async ({ request, page, log }) => {
|
|
13
|
+
router.addHandler('detail', async ({ request, page, log }) => {
|
|
18
14
|
const title = await page.title();
|
|
19
|
-
log.info(
|
|
20
|
-
|
|
15
|
+
log.info(`${title}`, { url: request.loadedUrl });
|
|
16
|
+
|
|
17
|
+
await Dataset.pushData({
|
|
18
|
+
url: request.loadedUrl,
|
|
19
|
+
title,
|
|
20
|
+
});
|
|
21
21
|
});
|
|
@@ -1,32 +1,51 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Specify the base Docker image. You can read more about
|
|
2
2
|
# the available images at https://crawlee.dev/docs/guides/docker-images
|
|
3
3
|
# You can also use any other image from Docker Hub.
|
|
4
|
-
FROM apify/actor-node:16 AS builder
|
|
4
|
+
FROM apify/actor-node-playwright-chrome:16 AS builder
|
|
5
5
|
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
COPY package*.json
|
|
9
|
-
COPY src ./src
|
|
6
|
+
# Copy just package.json and package-lock.json
|
|
7
|
+
# to speed up the build using Docker layer cache.
|
|
8
|
+
COPY --chown=myuser package*.json ./
|
|
10
9
|
|
|
11
|
-
# Install all dependencies
|
|
12
|
-
RUN npm install --include=dev
|
|
10
|
+
# Install all dependencies. Don't audit to speed up the installation.
|
|
11
|
+
RUN npm install --include=dev --audit=false
|
|
12
|
+
|
|
13
|
+
# Next, copy the source files using the user set
|
|
14
|
+
# in the base image.
|
|
15
|
+
COPY --chown=myuser . ./
|
|
16
|
+
|
|
17
|
+
# Install all dependencies and build the project.
|
|
18
|
+
# Don't audit to speed up the installation.
|
|
19
|
+
RUN npm run build
|
|
13
20
|
|
|
14
21
|
# Create final image
|
|
15
22
|
FROM apify/actor-node-playwright-chrome:16
|
|
16
23
|
|
|
17
|
-
# Copy only
|
|
18
|
-
COPY --from=builder
|
|
19
|
-
|
|
24
|
+
# Copy only built JS files from builder image
|
|
25
|
+
COPY --from=builder --chown=myuser /home/myuser/dist ./dist
|
|
26
|
+
|
|
27
|
+
# Copy just package.json and package-lock.json
|
|
28
|
+
# to speed up the build using Docker layer cache.
|
|
29
|
+
COPY --chown=myuser package*.json ./
|
|
20
30
|
|
|
21
|
-
# Install
|
|
31
|
+
# Install NPM packages, skip optional and development dependencies to
|
|
32
|
+
# keep the image small. Avoid logging too much and print the dependency
|
|
33
|
+
# tree for debugging
|
|
22
34
|
RUN npm --quiet set progress=false \
|
|
23
|
-
&& npm install --
|
|
35
|
+
&& npm install --omit=dev --omit=optional \
|
|
24
36
|
&& echo "Installed NPM packages:" \
|
|
25
|
-
&& (npm list --
|
|
37
|
+
&& (npm list --omit=dev --all || true) \
|
|
26
38
|
&& echo "Node.js version:" \
|
|
27
39
|
&& node --version \
|
|
28
40
|
&& echo "NPM version:" \
|
|
29
41
|
&& npm --version
|
|
30
42
|
|
|
31
|
-
#
|
|
32
|
-
|
|
43
|
+
# Next, copy the remaining files and directories with the source code.
|
|
44
|
+
# Since we do this after NPM install, quick build will be really fast
|
|
45
|
+
# for most source file changes.
|
|
46
|
+
COPY --chown=myuser . ./
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# Run the image. If you know you won't need headful browsers,
|
|
50
|
+
# you can remove the XVFB start script for a micro perf gain.
|
|
51
|
+
CMD ./start_xvfb_and_run_cmd.sh && npm run start:prod --silent
|
|
@@ -6,21 +6,3 @@ If you're looking for examples or want to learn more visit:
|
|
|
6
6
|
|
|
7
7
|
- [Documentation](https://crawlee.dev/api/playwright-crawler/class/PlaywrightCrawler)
|
|
8
8
|
- [Examples](https://crawlee.dev/docs/examples/playwright-crawler)
|
|
9
|
-
|
|
10
|
-
## Writing a README
|
|
11
|
-
|
|
12
|
-
See our tutorial on [writing READMEs for your actors](https://help.apify.com/en/articles/2912548-how-to-write-great-readme-for-your-actors) if you need more inspiration.
|
|
13
|
-
|
|
14
|
-
### Table of contents
|
|
15
|
-
|
|
16
|
-
If your README requires a table of contents, use the template below and make sure to keep the `<!-- toc start -->` and `<!-- toc end -->` markers.
|
|
17
|
-
|
|
18
|
-
<!-- toc start -->
|
|
19
|
-
- Introduction
|
|
20
|
-
- Use Cases
|
|
21
|
-
- Case 1
|
|
22
|
-
- Case 2
|
|
23
|
-
- Input
|
|
24
|
-
- Output
|
|
25
|
-
- Miscellaneous
|
|
26
|
-
<!-- toc end -->
|
|
@@ -3,19 +3,19 @@ import { Dataset, createPlaywrightRouter } from 'crawlee';
|
|
|
3
3
|
export const router = createPlaywrightRouter();
|
|
4
4
|
|
|
5
5
|
router.addDefaultHandler(async ({ enqueueLinks, log }) => {
|
|
6
|
-
log.info(`
|
|
6
|
+
log.info(`enqueueing new URLs`);
|
|
7
7
|
await enqueueLinks({
|
|
8
|
-
globs: ['https://crawlee.dev
|
|
9
|
-
label: '
|
|
8
|
+
globs: ['https://crawlee.dev/*'],
|
|
9
|
+
label: 'detail',
|
|
10
10
|
});
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
router.addHandler('
|
|
14
|
-
log.info(`Handle pagination`);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
router.addHandler('handleDetail', async ({ request, page, log }) => {
|
|
13
|
+
router.addHandler('detail', async ({ request, page, log }) => {
|
|
18
14
|
const title = await page.title();
|
|
19
|
-
log.info(
|
|
20
|
-
|
|
15
|
+
log.info(`${title}`, { url: request.loadedUrl });
|
|
16
|
+
|
|
17
|
+
await Dataset.pushData({
|
|
18
|
+
url: request.loadedUrl,
|
|
19
|
+
title,
|
|
20
|
+
});
|
|
21
21
|
});
|
|
@@ -1,15 +1,29 @@
|
|
|
1
|
+
# Specify the base Docker image. You can read more about
|
|
2
|
+
# the available images at https://crawlee.dev/docs/guides/docker-images
|
|
3
|
+
# You can also use any other image from Docker Hub.
|
|
1
4
|
FROM apify/actor-node-puppeteer-chrome:16
|
|
2
5
|
|
|
3
|
-
#
|
|
4
|
-
|
|
5
|
-
COPY
|
|
6
|
+
# Copy just package.json and package-lock.json
|
|
7
|
+
# to speed up the build using Docker layer cache.
|
|
8
|
+
COPY --chown=myuser package*.json ./
|
|
6
9
|
|
|
7
|
-
#
|
|
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
|
|
8
13
|
RUN npm --quiet set progress=false \
|
|
9
|
-
&& npm install --
|
|
14
|
+
&& npm install --omit=dev --omit=optional \
|
|
10
15
|
&& echo "Installed NPM packages:" \
|
|
11
|
-
&& (npm list --
|
|
16
|
+
&& (npm list --omit=dev --all || true) \
|
|
12
17
|
&& echo "Node.js version:" \
|
|
13
18
|
&& node --version \
|
|
14
19
|
&& echo "NPM version:" \
|
|
15
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.
|
|
25
|
+
COPY --chown=myuser . ./
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Run the image.
|
|
29
|
+
CMD npm start --silent
|
|
@@ -6,21 +6,3 @@ If you're looking for examples or want to learn more visit:
|
|
|
6
6
|
|
|
7
7
|
- [Documentation](https://crawlee.dev/api/puppeteer-crawler/class/PuppeteerCrawler)
|
|
8
8
|
- [Examples](https://crawlee.dev/docs/examples/puppeteer-crawler)
|
|
9
|
-
|
|
10
|
-
## Writing a README
|
|
11
|
-
|
|
12
|
-
See our tutorial on [writing READMEs for your actors](https://help.apify.com/en/articles/2912548-how-to-write-great-readme-for-your-actors) if you need more inspiration.
|
|
13
|
-
|
|
14
|
-
### Table of contents
|
|
15
|
-
|
|
16
|
-
If your README requires a table of contents, use the template below and make sure to keep the `<!-- toc start -->` and `<!-- toc end -->` markers.
|
|
17
|
-
|
|
18
|
-
<!-- toc start -->
|
|
19
|
-
- Introduction
|
|
20
|
-
- Use Cases
|
|
21
|
-
- Case 1
|
|
22
|
-
- Case 2
|
|
23
|
-
- Input
|
|
24
|
-
- Output
|
|
25
|
-
- Miscellaneous
|
|
26
|
-
<!-- toc end -->
|
|
@@ -3,19 +3,19 @@ import { Dataset, createPuppeteerRouter } from 'crawlee';
|
|
|
3
3
|
export const router = createPuppeteerRouter();
|
|
4
4
|
|
|
5
5
|
router.addDefaultHandler(async ({ enqueueLinks, log }) => {
|
|
6
|
-
log.info(`
|
|
6
|
+
log.info(`enqueueing new URLs`);
|
|
7
7
|
await enqueueLinks({
|
|
8
|
-
globs: ['https://crawlee.dev
|
|
9
|
-
label: '
|
|
8
|
+
globs: ['https://crawlee.dev/*'],
|
|
9
|
+
label: 'detail',
|
|
10
10
|
});
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
router.addHandler('
|
|
14
|
-
log.info(`Handle pagination`);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
router.addHandler('handleDetail', async ({ request, page, log }) => {
|
|
13
|
+
router.addHandler('detail', async ({ request, page, log }) => {
|
|
18
14
|
const title = await page.title();
|
|
19
|
-
log.info(
|
|
20
|
-
|
|
15
|
+
log.info(`${title}`, { url: request.loadedUrl });
|
|
16
|
+
|
|
17
|
+
await Dataset.pushData({
|
|
18
|
+
url: request.loadedUrl,
|
|
19
|
+
title,
|
|
20
|
+
});
|
|
21
21
|
});
|
|
@@ -1,32 +1,51 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Specify the base Docker image. You can read more about
|
|
2
2
|
# the available images at https://crawlee.dev/docs/guides/docker-images
|
|
3
3
|
# You can also use any other image from Docker Hub.
|
|
4
|
-
FROM apify/actor-node:16 AS builder
|
|
4
|
+
FROM apify/actor-node-puppeteer-chrome:16 AS builder
|
|
5
5
|
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
COPY package*.json
|
|
9
|
-
COPY src ./src
|
|
6
|
+
# Copy just package.json and package-lock.json
|
|
7
|
+
# to speed up the build using Docker layer cache.
|
|
8
|
+
COPY --chown=myuser package*.json ./
|
|
10
9
|
|
|
11
|
-
# Install all dependencies
|
|
12
|
-
RUN npm install --include=dev
|
|
10
|
+
# Install all dependencies. Don't audit to speed up the installation.
|
|
11
|
+
RUN npm install --include=dev --audit=false
|
|
12
|
+
|
|
13
|
+
# Next, copy the source files using the user set
|
|
14
|
+
# in the base image.
|
|
15
|
+
COPY --chown=myuser . ./
|
|
16
|
+
|
|
17
|
+
# Install all dependencies and build the project.
|
|
18
|
+
# Don't audit to speed up the installation.
|
|
19
|
+
RUN npm run build
|
|
13
20
|
|
|
14
21
|
# Create final image
|
|
15
22
|
FROM apify/actor-node-puppeteer-chrome:16
|
|
16
23
|
|
|
17
|
-
# Copy only
|
|
18
|
-
COPY --from=builder
|
|
19
|
-
|
|
24
|
+
# Copy only built JS files from builder image
|
|
25
|
+
COPY --from=builder --chown=myuser /home/myuser/dist ./dist
|
|
26
|
+
|
|
27
|
+
# Copy just package.json and package-lock.json
|
|
28
|
+
# to speed up the build using Docker layer cache.
|
|
29
|
+
COPY --chown=myuser package*.json ./
|
|
20
30
|
|
|
21
|
-
# Install
|
|
31
|
+
# Install NPM packages, skip optional and development dependencies to
|
|
32
|
+
# keep the image small. Avoid logging too much and print the dependency
|
|
33
|
+
# tree for debugging
|
|
22
34
|
RUN npm --quiet set progress=false \
|
|
23
|
-
&& npm install --
|
|
35
|
+
&& npm install --omit=dev --omit=optional \
|
|
24
36
|
&& echo "Installed NPM packages:" \
|
|
25
|
-
&& (npm list --
|
|
37
|
+
&& (npm list --omit=dev --all || true) \
|
|
26
38
|
&& echo "Node.js version:" \
|
|
27
39
|
&& node --version \
|
|
28
40
|
&& echo "NPM version:" \
|
|
29
41
|
&& npm --version
|
|
30
42
|
|
|
31
|
-
#
|
|
32
|
-
|
|
43
|
+
# Next, copy the remaining files and directories with the source code.
|
|
44
|
+
# Since we do this after NPM install, quick build will be really fast
|
|
45
|
+
# for most source file changes.
|
|
46
|
+
COPY --chown=myuser . ./
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# Run the image. If you know you won't need headful browsers,
|
|
50
|
+
# you can remove the XVFB start script for a micro perf gain.
|
|
51
|
+
CMD ./start_xvfb_and_run_cmd.sh && npm run start:prod --silent
|
|
@@ -6,21 +6,3 @@ If you're looking for examples or want to learn more visit:
|
|
|
6
6
|
|
|
7
7
|
- [Documentation](https://crawlee.dev/api/puppeteer-crawler/class/PuppeteerCrawler)
|
|
8
8
|
- [Examples](https://crawlee.dev/docs/examples/puppeteer-crawler)
|
|
9
|
-
|
|
10
|
-
## Writing a README
|
|
11
|
-
|
|
12
|
-
See our tutorial on [writing READMEs for your actors](https://help.apify.com/en/articles/2912548-how-to-write-great-readme-for-your-actors) if you need more inspiration.
|
|
13
|
-
|
|
14
|
-
### Table of contents
|
|
15
|
-
|
|
16
|
-
If your README requires a table of contents, use the template below and make sure to keep the `<!-- toc start -->` and `<!-- toc end -->` markers.
|
|
17
|
-
|
|
18
|
-
<!-- toc start -->
|
|
19
|
-
- Introduction
|
|
20
|
-
- Use Cases
|
|
21
|
-
- Case 1
|
|
22
|
-
- Case 2
|
|
23
|
-
- Input
|
|
24
|
-
- Output
|
|
25
|
-
- Miscellaneous
|
|
26
|
-
<!-- toc end -->
|
|
@@ -3,19 +3,19 @@ import { Dataset, createPuppeteerRouter } from 'crawlee';
|
|
|
3
3
|
export const router = createPuppeteerRouter();
|
|
4
4
|
|
|
5
5
|
router.addDefaultHandler(async ({ enqueueLinks, log }) => {
|
|
6
|
-
log.info(`
|
|
6
|
+
log.info(`enqueueing new URLs`);
|
|
7
7
|
await enqueueLinks({
|
|
8
|
-
globs: ['https://crawlee.dev
|
|
9
|
-
label: '
|
|
8
|
+
globs: ['https://crawlee.dev/*'],
|
|
9
|
+
label: 'detail',
|
|
10
10
|
});
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
router.addHandler('
|
|
14
|
-
log.info(`Handle pagination`);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
router.addHandler('handleDetail', async ({ request, page, log }) => {
|
|
13
|
+
router.addHandler('detail', async ({ request, page, log }) => {
|
|
18
14
|
const title = await page.title();
|
|
19
|
-
log.info(
|
|
20
|
-
|
|
15
|
+
log.info(`${title}`, { url: request.loadedUrl });
|
|
16
|
+
|
|
17
|
+
await Dataset.pushData({
|
|
18
|
+
url: request.loadedUrl,
|
|
19
|
+
title,
|
|
20
|
+
});
|
|
21
21
|
});
|