extractlinks

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2019 License: MIT Imports: 4 Imported by: 2

README

Actions Status

extractlinks GO package for extracting anchor links from HTML

Extracts all anchor links from a HTML page into an Array of []Link

type Link struct {
	Href string
	Text string
}

Install

go get -u github.com/steelx/extractlinks

Example

package main

import (
  "fmt"
  "net/http"
  
  "github.com/steelx/extractlinks"
)

func main() {
  resp, _ := http.Get("http://www.youtube.com/JsFunc")
  links, err := extractlinks.All(resp.Body)
  checkErr(err)
  
  fmt.Println(links)
}

Output: (... is just to suppress rest of the result)

[{/ IN} {//www.youtube.com/upload } {/channel/UCuB4FSBjofpagXnBlHQUocA } ...]

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Version

func Version() string

Version returns the current 'extractlinks' version

Types

type Link struct {
	Href string
	Text string
}

Link object for parsing an anchor link

func All

func All(htmlBody io.Reader) ([]Link, error)

All takes a reader object (like the one returned from http.Get()) It returns a slice of Links representing the Href & Text attributes from anchor links found in the provided html. 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