Skip to content

Three layered API template for web scrapping with puppeteer using TS.

Notifications You must be signed in to change notification settings

frankymelero/scrapping-api-puppeteer-express

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scrapping Api Template

This template is an API with a 3-layer architecture using TypeScript and Express. The API uses Puppeteer to perform web scraping.

Table of Contents

  1. Installation
  2. Project Structure
  3. Usage
  4. Endpoints
  5. Contact

Installation

  1. Clone the repository:

    git clone https://github.com/frankymelero/scrapping-api-puppeteer-express
    cd scrapping-api-puppeteer-express
  2. Install dependencies:

    npm install

Project Structure

scrapping-api-puppeteer-express/
├── src/
│   ├── controllers/
│   │   └── scrape.controller.ts
│   ├── services/
│   │   └── scrape.service.ts
│   ├── repositories/
│   │   └── scrape.repository.ts
│   ├── routes/
│   │   └── scrape.route.ts
│   └── index.ts
├── package.json
├── tsconfig.json
└── README.md

Usage

  1. Compile the project:

    npm run build
  2. Start the server:

    npm start

Endpoints

GET /api/scrape

This endpoint scrapes the provided URL to get the title.

  • URL: /api/scrape

  • Method: GET

  • Query Parameters:

    • url (required): The URL of the website to scrape.
  • Response:

    • 200 OK: Returns the scraping result.
    • 400 Bad Request: If the URL parameter is missing.
    • 500 Internal Server Error: If an error occurs during scraping.

Example Request:

GET /api/scrape?url=https://example.com

Example result

{
  "result": "Example Domain"
}

Contact

For any questions, feedback, or issues, please feel free to reach out:

About

Three layered API template for web scrapping with puppeteer using TS.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published