Skip to content

Lightweight go library for pulling data out of HTML, inspired by BeautifulSoup and Jsoup

License

Notifications You must be signed in to change notification settings

gurkankaymak/gosoup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gosoup

Go Report Card GoDoc Build Status

Lightweight go library for pulling data out of HTML

it provides a convenient API for constructing and manipulating data, inspired by BeautifulSoup and Jsoup

Installation

go get -u github.com/gurkankaymak/gosoup

API Overview

Find(tagName string, attributes Attributes) *Element // returns the first occurrence of the node with the given tagName and attributes
FindByTag(tagName string) *Element // returns the first occurrence of the node with the given tagName
FindByAttributes(attributes Attributes) *Element // returns the first occurrence of the node with the given attributes

FindAll(tagName string, attributes Attributes) []*Element // returns all nodes with the given tagName and attributes
FindAllByTag(tagName string) []*Element // returns all nodes with the given tagName
FindAllByAttributes(attributes Attributes) []*Element // returns all nodes with the given attributes

Usage

element, err := gosoup.ParseAsHTML("... html as string ...")
if err != nil {
    // log/handle error
    return err
}
loginElement := element.Find("form", gosoup.Attributes{"name": "login", "class": "loginTable"})
if loginElement == nil {
    fmt.Println("could not find login element")
}
fmt.Println("loginElement:", loginElement)

About

Lightweight go library for pulling data out of HTML, inspired by BeautifulSoup and Jsoup

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages