htmlrefs

package module
v0.0.0-...-46ee555 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2015 License: MIT Imports: 2 Imported by: 1

README

htmlrefs

Package htmlrefs returns a slice of Reference{URI, Token string}s from an io.Reader.

usage
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
$ 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 References

type Reference struct {
    URI, Token string
}
credits

Inspired by https://github.com/JackDanger/collectlinks

Documentation

Overview

Package htmlrefs returns a slice of `Reference{URI, Token string}`s from an `io.Reader`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reference

type Reference struct{ URI, Token string }

`Reference` are simply two strings: a `URI` and a `Token`

func All

func All(httpBody io.Reader) []Reference

`All` takes a reader object (like the one returned from http.Get()) It returns a slice of struct Reference{uri, nodetype} It does not close the reader passed to it.

Jump to

Keyboard shortcuts

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