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 ¶
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 ¶
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 ¶
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'.