A simple Go library to get all the links from an HTML page
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.travis.yml
README.md
getlinks.go
getlinks_test.go
go.mod

README.md

getlinks

travis go report card coverage godocs

A very simple way to get links from web page. This library uses the domain of the webpage to correctly parse relative links.

Install

go get -u github.com/schollz/getlinks

Usage

urlString := "https://en.wikipedia.org/w/index.php?title=Pauli_exclusion_principle&oldid=854810355"
resp, _ := http.Get(urlString)
htmlBytes, _ := ioutil.ReadAll(resp.Body)
resp.Body.Close()

// get all links
links, _ := getlinks.GetLinks(htmlBytes, urlString)
fmt.Println(links)

Contributing

Pull requests are welcome. Feel free to...

  • Revise documentation
  • Add new features
  • Fix bugs
  • Suggest improvements

License

MIT