xtract

package module
v0.0.0-...-b7fe05e Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2018 License: MIT Imports: 6 Imported by: 0

README

xtract

xtract text from html

Usage:

// Extract all text from the page
xtract.Page("https://github.com/golovers")

// Extract the first 20 words from the page
xtract.PageLim("https://github.com/golovers", 20)

// Extract all text from html value
xtract.Value("<div>Text</div>")

// Extract the first word in the html value
xtract.ValueLim("<div>Text and another text</div>", 1)

// Override trim function if needed
xtract.SetTrimFunc(f TrimFunc)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Page

func Page(url string) (string, error)

Page extract text from the given url

func PageLim

func PageLim(url string, lim int) (string, error)

PageLim extract text from the page and return upto lim number of words

func SetTrimFunc

func SetTrimFunc(f TrimFunc)

SetTrimFunc set trim function, default is trim left/right spaces with unicode.IsSpace

func Value

func Value(htmlVal string) string

Value extract text from the given html value

func ValueLim

func ValueLim(htmlVal string, lim int) string

ValueLim extract text from the given html value and return upto lim number of words

Types

type TrimFunc

type TrimFunc func(r rune) bool

TrimFunc trim function applied in resule

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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