html-parser

module
v0.0.0-...-f882165 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2023 License: MIT

README

HTML Parser

Go Report Card

This project is a tool for providing HTML parsing via a RESTful API endpoint.

Prerequisites

CLI Tools

Example

API Request

const url = 'https://.../v1/html-parser';

const body = {
  html: '<html>...</html>',
  properties: [
    {
      name: 'title',
      selector: '.product .title',
    },
    {
      name: 'details',
      selector: '.product .details ul li',
    },
    {
      name: 'image',
      selector: '.product img',
      attribute: 'src',
    },
  ],
};

const options = {
  method: 'POST',
  body: JSON.stringify(body),
};

return fetch(url, options)
  .then((response) => response.json())
  .catch((e) => console.log(e));

Successful Response

{
  "title": [
    "Men's Columbia Flattop Ridge Fleece Jacket"
  ],
  "image": [
    "https://....com/images/clothing/2599191_ALT-1000.jpg"
  ],
  "details": [
    "Polyester fleece",
    "Machine wash",
    "Imported",
  ],
}

Failure Response

{
  "error": "no properties found"
}

Directories

Path Synopsis
pkg
log
req

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL