rbehzadan/extract-text-api

By rbehzadan

Updated about 2 years ago

FastAPI service to extract and return cleaned text from HTML content using Goose3.

Image
Machine learning & AI
Data science
0

493

rbehzadan/extract-text-api repository overview

FastAPI Goose3 HTML Content Extractor

Description

The FastAPI Goose3 HTML Content Extractor is a REST API service designed to extract and return cleaned text from HTML content. It leverages the power of FastAPI for high-performance HTTP handling and Goose3 for effective content extraction from HTML.

Features
  • FastAPI: A modern, fast (high-performance), web framework for building APIs with Python 3.8+.
  • Goose3: A library that extracts the main content from web pages, removing ads, navigation, and other non-essential elements.
  • Efficient: Handles large HTML content efficiently with support for multiple workers.
Usage

To run this Docker image, use the following command:

docker run -d -p 8000:8080 rbehzadan/extract-text-api:latest

This command will start the FastAPI application on port 8000.

API Endpoint
POST /extract-text

Description: Extracts and returns the main text content from provided HTML.

Request:

  • URL: /extract-text
  • Method: POST
  • Content-Type: application/json
  • Body:
    {
      "content": "<html><body><h1>Sample Article</h1><p>This is a sample paragraph.</p></body></html>"
    }
    

Response:

  • Content-Type: application/json
  • Body:
    {
      "text": "Sample Article\nThis is a sample paragraph."
    }
    
Environment Variables

You can customize the number of Uvicorn workers by setting the --workers flag (Default number of workers is 1). Modify the Docker run command if needed:

docker run -d -p 8000:8080 rbehzadan/extract-text-api:latest uvicorn main:app --host 0.0.0.0 --port 8080 --workers 4
Example Usage

Send a POST request to the /extract-text endpoint with the HTML content you want to process. The service will respond with the cleaned text.

Source Code

The source code for this project is available on GitHub: https://github.com/rbehzadan/extract-text-api

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on the GitHub repository for any changes.

Tag summary

Content type

Image

Digest

sha256:edafb8058

Size

75 MB

Last updated

about 2 years ago

docker pull rbehzadan/extract-text-api