internal

package
v1.0.1-0...-86d6993 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB = []byte("DB")

DB the root bucket name

View Source
var Entries = []byte("ENTRIES")

Entries the data bucket name

Functions

This section is empty.

Types

type Collector

type Collector struct {
	*colly.Collector // extend colly.Collector
	// contains filtered or unexported fields
}

Collector data collector

func NewCollector

func NewCollector(script *Script, db *bolt.DB) *Collector

NewCollector return an extended colly.Collector configured just the way Skrapa likes it based on the given script

func (Collector) Run

func (c Collector) Run()

Run execute the data collection

type Exporter

type Exporter struct {
	// contains filtered or unexported fields
}

Exporter parse scripts

func NewExporter

func NewExporter(db *bolt.DB) *Exporter

NewExporter return a new script parser

func (Exporter) ExportCSV

func (e Exporter) ExportCSV(filename string) error

ExportCSV export database as CSV

func (Exporter) ExportJSON

func (e Exporter) ExportJSON(filename string) error

ExportJSON export database as JSON

type PipelineItem

type PipelineItem struct {
	Selector  string `toml:"selector"`
	Action    string `toml:"action"`
	Attribute string `toml:"attr"`
	Column    string `toml:"column,omitempty"`
	VisitOnce bool   `toml:"visit_once,omitempty"`
}

PipelineItem models a Skrapa pipeline item

type Script

type Script struct {
	Main struct {
		URL            string   `toml:"url"`
		File           string   `toml:"file"`
		Format         string   `toml:"format"`
		UserAgent      string   `toml:"user_agent,omitempty"`
		Delay          int      `toml:"delay,omitempty"`
		AllowedDomains []string `toml:"allowed_domains,omitempty"`
	} `toml:"main"`
	Pipeline []*PipelineItem `toml:"pipeline"`
}

Script models the Skrapa TOML config

type ScriptParser

type ScriptParser struct{}

ScriptParser parse scripts

func NewScriptParser

func NewScriptParser() *ScriptParser

NewScriptParser return a new script parser

func (ScriptParser) Parse

func (p ScriptParser) Parse(fileName string) (*Script, error)

Parse do the parsing of scripts

Jump to

Keyboard shortcuts

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