This is a Node.js-based API server that allows dynamic execution of Puppeteer scripts for web scraping and automation tasks.
- Dynamic script execution via REST API
- Puppeteer-powered web scraping
- Containerized deployment
- Docker
- Docker Compose
- Node.js 18+
git clone <your-repository-url>
cd puppeteer-api-server
Using Docker Compose:
docker-compose up -d
- URL:
http://localhost:44444/run-script
- Method: POST
- Request Body:
{ "script": "scriptName.js", "url": "/path/to/page" }
server.js
: Express server handling script executionDockerfile
: Docker configuration for the applicationdocker-compose.yaml
: Docker Compose configurationscripts/
: Directory for custom Puppeteer scriptspackage.json
: Node.js project dependencies
Place Puppeteer scripts in the scripts/
directory. Each script should export an async function that takes browser
and url
as parameters.
Example script structure:
module.exports = async (browser, url) => {
const page = await browser.newPage();
await page.goto(url);
// Perform scraping or automation tasks
return results;
};
- Scripts run in a sandboxed environment
- URL normalization prevents arbitrary website access
- Runs with minimal Docker container privileges
Server logs are output to the console, providing insights into script execution and potential errors.
- Ensure Docker is running
- Check container logs:
docker-compose logs puppeteer
- Verify script syntax and Puppeteer compatibility
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the GNU General Public License v3.0 (GPL-3.0). See the LICENSE file for details.
This tool is for educational and authorized testing purposes only. Always respect website terms of service and legal guidelines when web scraping.
[Il Gigante/Tana del Gigante]