spa

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: MIT Imports: 5 Imported by: 0

README

SPA - Single Page App Processor

A Single Page App processor using go-rod/rod

Change Log
  • v0.0.1
    • Initial commit
  • v0.0.2
    • cleanup
    • ScrollOffset use float64
  • v0.0.3
    • update ezlog
  • v0.0.4
    • V000_LoadPage only wait if loading page
License

The MIT License (MIT)

Copyright © 2025 John, Sing Dao, Siu john.sd.siu@gmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Overview

Copyright © 2025 John, Sing Dao, Siu <john.sd.siu@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright © 2025 John, Sing Dao, Siu <john.sd.siu@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright © 2025 John, Sing Dao, Siu <john.sd.siu@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IInfo

type IInfo interface {
	GetMatched() bool
	GetMatchedStr() string
	SetMatched(matched bool)
	SetMatchedStr(matchedStr string)
	String() string
}

type Info

type Info struct {
	GetMatched    func() bool
	GetMatchedStr func() string
	SetMatched    func(matched bool)
	SetMatchedStr func(matchedStr string)
	String        func() string
}

type Processor

type Processor struct {
	*basetype.Base

	Container       *rod.Element
	InfoList        []IInfo
	InfoListEnabled bool
	PageP           *rod.Page
	ScrollOffset    float64 // TODO: maybe not required
	ScrollSleep     int     // TODO: maybe not required
	Url             string

	// IProcess                   func(loadUrl bool, checkURL bool, scrollMax int)
	V000_LoadPage              func(urlStr string, loadUrl bool, checkUrl bool)
	V010_ElementsContainer     func() *rod.Element
	V020_Elements              func(element *rod.Element) *rod.Elements
	V030_ElementInfo           func(element *rod.Element, index int) (infoP IInfo)
	V040_ElementMatch          func(element *rod.Element, index int, infoP IInfo) (matched bool, matchedStr string)
	V050_ElementProcessMatched func(element *rod.Element, index int, infoP IInfo)
	V060_ElementProcessUnmatch func(element *rod.Element, index int, infoP IInfo)
	V070_ElementProcess        func(element *rod.Element, index int, infoP IInfo)
	V080_ElementScrollable     func(element *rod.Element, index int, infoP IInfo) bool
	V090_ElementLoopEnd        func(element *rod.Element, index int, infoP IInfo)
	V100_ScrollLoopEnd         func(state *RunState)
}

SPA Processor

func New

func New(pageP *rod.Page, urlStr string, debug bool) *Processor

func (*Processor) ElementScroll

func (p *Processor) ElementScroll(element *rod.Element, scrollOffset float64, scrollSleep int)

func (*Processor) Reset

func (p *Processor) Reset() *Processor

func (*Processor) Run

func (p *Processor) Run(loadUrl bool, checkURL bool, scrollMax int)

type RunState

type RunState struct {
	*basetype.Base

	Elements          *rod.Elements
	ElementLast       *rod.Element
	ElementLastScroll *rod.Element
	ElementCountLast  int
	ListItemLast      IInfo
	Scroll            bool
	ScrollCount       int
}

SPA Processor Run State

func (*RunState) New

func (s *RunState) New() *RunState

func (*RunState) String

func (s *RunState) String() *string

This should only be used at Trace level log

Jump to

Keyboard shortcuts

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