HUB
Sign inSign up

tbelbek/postlight-readability-parser

By tbelbek

•Updated about 2 years ago

Postlight/Readability Parser

Image
Content management system
Web analytics
0

863

tbelbek/postlight-readability-parser repository overview

Postlight Readability Parser

This Docker image provides a simple API for parsing web pages using the @postlight/parser and @mozilla/readability libraries.

Features

  • Parse web pages to extract meaningful content
  • Supports both @postlight/parser and @mozilla/readability
  • Easy to deploy with Docker

⁠API Endpoints

⁠GET /parser

Fetch and parse a URL using @postlight/parser.

⁠Request
curl -X GET "http://localhost/parser?url=https://example.com"
⁠Response

{ "title": "Example Domain", "content": "

This domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.

<p style="font-size: smaller; font-style: italic;">Parsed by PP

", "author": null, "date_published": null, "lead_image_url": null, "dek": null, "next_page_url": null, "url": "https://example.com⁠", "domain": "example.com", "excerpt": "This domain is for use in illustrative examples in documents.", "word_count": 19, "direction": "ltr", "total_pages": 1, "rendered_pages": 1 }

⁠POST /

Fetch and parse a URL using @mozilla/readability.

curl -X POST "http://localhost/" -H "Content-Type: application/json" -d '{"url": "https://example.com"}'
⁠Response
{
  "title": "Example Domain",
  "content": "<div>This domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.</div><p style=\"font-size: smaller; font-style: italic;\">Parsed by PP</p>",
  "textContent": "This domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.",
  "length": 123,
  "excerpt": "This domain is for use in illustrative examples in documents.",
  "byline": null,
  "dir": "ltr"
}
⁠Error Handling

If the URL is invalid or the page cannot be parsed, the API will return a 400 status code with an error message.

{
  "error": "Failed to fetch and parse the URL"
}
Tag summary
Recent tags
Content type
Image
Digest
sha256:7ca0f3436…
Size
358 MB
Last updated
about 2 years ago
docker pull tbelbek/postlight-readability-parser:latest