Code Monkey home page Code Monkey logo

fetch-url-api's Introduction

Fetch URL API Service

This project is a REST API service built with Node.js and Express, leveraging Playwright to fetch the final rendered content of a given URL. The service returns the HTML content of the URL, optionally using a proxy server.

Prerequisites

  • Node.js and npm installed
  • Docker installed

Installation

  1. Clone the repository:

    git clone https://github.com/rbehzadan/fetch-url-api.git
    cd fetch-url-api
  2. Install the dependencies:

    npm install

Usage

Running the Service Locally

  1. Start the server:

    node server.js
  2. Send a request to the API:

    You can use curl, Postman, or any HTTP client to send a POST request to the server.

    curl -X POST http://localhost:8080/fetch \
        -H "Content-Type: application/json" \
        -d '{"url":"https://example.com", "proxy":"http://proxyserver:port"}'

    Note: The proxy field is optional.

Running the Service with Docker

  1. Build the Docker image:

    docker build -t fetch-url-api .
  2. Run the Docker container:

    docker run -p 8080:8080 fetch-url-api
  3. Send a request to the API:

    curl -X POST http://localhost:8080/fetch \
        -H "Content-Type: application/json" \
        -d '{"url":"https://example.com", "proxy":"http://proxyserver:port"}'

    Note: The proxy field is optional.

API Endpoints

POST /fetch

Fetches the final rendered HTML content of the provided URL.

Request Body:

  • url (string): The URL to fetch the content from. (Required)
  • proxy (string): The proxy server to use. (Optional)

Response:

  • content (string): The rendered HTML content of the URL.

Example Request:

{
  "url": "https://example.com",
  "proxy": "http://proxyserver:port"
}

Example Response:

{
  "content": "<html>...</html>"
}

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

Acknowledgments

fetch-url-api's People

Contributors

rbehzadan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.