apify-docs
apify-docs copied to clipboard
'Running a web server' should go under Tutorials
The page Running a web server on the Apify platform is standalone and seems to be a specific solution to a very specific problem. IMHO it is a how-to guide and should go under Tutorials.
(Aside the fact that it is also platform-specific and long-term might not even belong to the Academy as we envision it.)
And readers suggest changes to this page:
Could be useful to suggest to start from the crawlee-puppeteer-chrome template. The code is outdated. The line
await Actor.init();should be added to the beginning of the file. The lineconst browser = await Actor.launchPuppeteer();should be replaced withconst browser = await launchPuppeteer(), with the importimport { launchPuppeteer } from "crawlee";. The POST URL should be relative.
import { Actor } from "apify";
import express from "express";
import { launchPuppeteer } from "crawlee";
await Actor.init()
[...]
app.get("/", (req, res) => {
[...]
<form method="POST" action="/add-url">
[...]
});
app.post("/add-url", async (req, res) => {
const { url } = req.body;
console.log(`Got new URL: ${url}`);
// Start chrome browser and open new page ...
const browser = await launchPuppeteer()
[...]
});
[...]