html

package
v0.0.0-...-e092c70 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Copyright © 2020 Mateusz Kurowski

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var CollectSelectorAttributes = func(selectors map[string][]string) GoQueryCollectFunc {
	return func(doc *goquery.Document) (values []string) {
		for selector, attributes := range selectors {
			doc.Find(selector).Each(func(i int, selection *goquery.Selection) {
				for _, attribute := range attributes {
					if value, exists := selection.Attr(attribute); exists {
						values = append(values, value)
					}
				}
			})
		}
		return values
	}
}

CollectSelectorAttribute gathers attributes for given selectors. Example:

var selectors = map[string][]string{"a": {"href"}}

Functions

This section is empty.

Types

type Collector

type Collector interface {
	Collect(r io.Reader, w io.Writer) error
}

Collector is responsible for collecting items from reader writing them to writer.

func NewGoQueryCollector

func NewGoQueryCollector(collect ...GoQueryCollectFunc) Collector

NewGoQueryCollector returns new GoQueryCollector.

type GoQueryCollectFunc

type GoQueryCollectFunc = func(doc *goquery.Document) []string

GoQueryCollectFunc is a function that gathers items from given goquery.Document.

type GoQueryCollector

type GoQueryCollector struct {
	Collector
	CollectFunc []GoQueryCollectFunc
}

GoQueryCollector is a basic Collector implementation based on 'github.com/PuerkitoBio/goquery'.

func (*GoQueryCollector) Collect

func (c *GoQueryCollector) Collect(r io.Reader, w io.Writer) error

Jump to

Keyboard shortcuts

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