https://github.com/weisjohn/htmlrefs
Package htmlrefs returns a slice of `Reference{URI, Token string}`s from an `io.Reader`.
https://github.com/weisjohn/htmlrefs
Last synced: over 1 year ago
JSON representation
Package htmlrefs returns a slice of `Reference{URI, Token string}`s from an `io.Reader`.
- Host: GitHub
- URL: https://github.com/weisjohn/htmlrefs
- Owner: weisjohn
- License: mit
- Created: 2015-02-12T07:07:53.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-02-17T17:13:30.000Z (over 11 years ago)
- Last Synced: 2025-01-24T04:44:39.642Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 141 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# htmlrefs
Package htmlrefs returns a slice of `Reference{URI, Token string}`s from an `io.Reader`.
### usage
```go
package main
import (
"fmt"
"net/http"
"github.com/weisjohn/htmlrefs"
)
func main() {
resp, _ := http.Get("http://johnweis.com")
refs := htmlrefs.All(resp.Body)
for _, ref := range refs {
fmt.Println(ref.Token, ":", ref.URI)
}
}
```
### output
```bash
$ go run example-htmlrefs.go
link : /favicon.ico
link : /css/main.css
a : /
a : /talks
a : /projects
a : http://www.clevertech.biz/
a : /talks
a : /projects
script : /components/jquery/dist/jquery.min.js
script : /components/bootstrap/dist/js/bootstrap.min.js
```
### struct
`htmlrefs` returns a slice of `Reference`s
```go
type Reference struct {
URI, Token string
}
```
### credits
Inspired by https://github.com/JackDanger/collectlinks