converthtmltabletodata

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 6 Imported by: 1

README

HTML-Table-to-JSON

The package allows you to extract the data from an html table

Example Usage:

func main() {
	data, err := converthtmltabletodata.ConvertURLToJSON("src/index.html")
	if err != nil { return }
	jsonFile, err := os.Create("jsonData.json")
	if err != nil { return }
	defer jsonFile.Close()

	_, err = jsonFile.Write(data)
	if err != nil { return }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertReaderToJSON

func ConvertReaderToJSON(reader io.ReadCloser) ([]byte, error)

func ConvertURLToJSON

func ConvertURLToJSON(filePath string) ([]byte, error)

Types

type Row

type Row map[string]string

Row represents a single row in a table. It is a map from header string to data string.

type Table

type Table []Row

Table represents a table as a slice of Rows.

func Convert

func Convert(reader io.ReadCloser) ([]Table, error)

Convert takes an io.ReadCloser and returns Tables and an error. The Tables are Rows, where each Row is a hashmap with the header string has the key. If there is an error reading from the input or parsing the HTML, Convert returns the Tables processed so far and the error.

func ConvertUrl

func ConvertUrl(filePath string) ([]Table, error)

Jump to

Keyboard shortcuts

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