parser

package
v0.0.0-...-11d5444 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2022 License: MIT Imports: 7 Imported by: 0

README

Given an extractor and an html page, the parser will convert that into a well defined type with well known extraction methods.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrParsePageType = errors.New("failed to parse requested page type")

Functions

func ParseAjaxPage

func ParseAjaxPage[T AjaxPagePages](e extractor.Extractor, pageHTML []byte) (T, error)

func ParsePage

func ParsePage[T FullPagePages](e extractor.Extractor, pageHTML []byte) (T, error)

ParsePage given a pageHTML and an extractor for the game version this html represent, returns a page of type T

Types

type DefensesPage

type DefensesPage struct{ FullPage }

func (DefensesPage) ExtractDefense

func (p DefensesPage) ExtractDefense() (ogame.DefensesInfos, error)

type EventListAjaxPage

type EventListAjaxPage struct{ Page }

func (EventListAjaxPage) ExtractAttacks

func (p EventListAjaxPage) ExtractAttacks(ownCoords []ogame.Coordinate) ([]ogame.AttackEvent, error)

type FacilitiesPage

type FacilitiesPage struct{ FullPage }

func (FacilitiesPage) ExtractFacilities

func (p FacilitiesPage) ExtractFacilities() (ogame.Facilities, error)

type FetchTechsAjaxPage

type FetchTechsAjaxPage struct{ Page }

type FullPage

type FullPage struct{ Page }

func (FullPage) ExtractAdmiral

func (p FullPage) ExtractAdmiral() bool

func (FullPage) ExtractAjaxChatToken

func (p FullPage) ExtractAjaxChatToken() (string, error)

func (FullPage) ExtractCelestial

func (p FullPage) ExtractCelestial(v any) (ogame.Celestial, error)

func (FullPage) ExtractCelestials

func (p FullPage) ExtractCelestials() ([]ogame.Celestial, error)

func (FullPage) ExtractCharacterClass

func (p FullPage) ExtractCharacterClass() (ogame.CharacterClass, error)

func (FullPage) ExtractCommander

func (p FullPage) ExtractCommander() bool

func (FullPage) ExtractEngineer

func (p FullPage) ExtractEngineer() bool

func (FullPage) ExtractGeologist

func (p FullPage) ExtractGeologist() bool

func (FullPage) ExtractIsInVacation

func (p FullPage) ExtractIsInVacation() bool

func (FullPage) ExtractLifeformEnabled

func (p FullPage) ExtractLifeformEnabled() bool

func (FullPage) ExtractMoon

func (p FullPage) ExtractMoon(v any) (ogame.Moon, error)

func (FullPage) ExtractMoons

func (p FullPage) ExtractMoons() []ogame.Moon

func (FullPage) ExtractOGameSession

func (p FullPage) ExtractOGameSession() string

func (FullPage) ExtractPlanet

func (p FullPage) ExtractPlanet(v any) (ogame.Planet, error)

func (FullPage) ExtractPlanets

func (p FullPage) ExtractPlanets() []ogame.Planet

func (FullPage) ExtractServerTime

func (p FullPage) ExtractServerTime() (time.Time, error)

func (FullPage) ExtractTechnocrat

func (p FullPage) ExtractTechnocrat() bool

type IFullPage

type IFullPage interface {
	ExtractOGameSession() string
	ExtractIsInVacation() bool
	ExtractPlanets() []ogame.Planet
	ExtractAjaxChatToken() (string, error)
	ExtractCharacterClass() (ogame.CharacterClass, error)
	ExtractCommander() bool
	ExtractAdmiral() bool
	ExtractEngineer() bool
	ExtractGeologist() bool
	ExtractTechnocrat() bool
	ExtractServerTime() (time.Time, error)
}

func AutoParseFullPage

func AutoParseFullPage(e extractor.Extractor, pageHTML []byte) (out IFullPage)

type LfBuildingsPage

type LfBuildingsPage struct{ FullPage }

func (LfBuildingsPage) ExtractLfBuildings

func (p LfBuildingsPage) ExtractLfBuildings() (ogame.LfBuildings, error)

type LfResearchPage

type LfResearchPage struct{ FullPage }

func (LfResearchPage) ExtractLfResearch

func (p LfResearchPage) ExtractLfResearch() (ogame.LfResearches, error)

type MissileAttackLayerAjaxPage

type MissileAttackLayerAjaxPage struct{ Page }

func (MissileAttackLayerAjaxPage) ExtractIPM

func (p MissileAttackLayerAjaxPage) ExtractIPM() (int64, int64, string)

type MovementPage

type MovementPage struct{ FullPage }

func (MovementPage) ExtractCancelFleetToken

func (p MovementPage) ExtractCancelFleetToken(fleetID ogame.FleetID) (string, error)

func (MovementPage) ExtractFleets

func (p MovementPage) ExtractFleets() []ogame.Fleet

func (MovementPage) ExtractSlots

func (p MovementPage) ExtractSlots() ogame.Slots

type OverviewPage

type OverviewPage struct{ FullPage }

func (OverviewPage) ExtractActiveItems

func (p OverviewPage) ExtractActiveItems() ([]ogame.ActiveItem, error)

func (OverviewPage) ExtractCancelBuildingInfos

func (p OverviewPage) ExtractCancelBuildingInfos() (token string, techID, listID int64, err error)

func (OverviewPage) ExtractCancelLfBuildingInfos

func (p OverviewPage) ExtractCancelLfBuildingInfos() (token string, id, listID int64, err error)

func (OverviewPage) ExtractCancelResearchInfos

func (p OverviewPage) ExtractCancelResearchInfos() (token string, techID, listID int64, err error)

func (OverviewPage) ExtractConstructions

func (p OverviewPage) ExtractConstructions() (ogame.ID, int64, ogame.ID, int64, ogame.ID, int64, ogame.ID, int64)

func (OverviewPage) ExtractDMCosts

func (p OverviewPage) ExtractDMCosts() (ogame.DMCosts, error)

func (OverviewPage) ExtractUserInfos

func (p OverviewPage) ExtractUserInfos() (ogame.UserInfos, error)

type Page

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

func (*Page) GetContent

func (p *Page) GetContent() []byte

func (*Page) GetDoc

func (p *Page) GetDoc() *goquery.Document

type PhalanxAjaxPage

type PhalanxAjaxPage struct{ Page }

func (PhalanxAjaxPage) ExtractPhalanx

func (p PhalanxAjaxPage) ExtractPhalanx() ([]ogame.Fleet, error)

type PreferencesPage

type PreferencesPage struct{ FullPage }

func (PreferencesPage) ExtractPreferences

func (p PreferencesPage) ExtractPreferences() ogame.Preferences

type ResearchPage

type ResearchPage struct{ FullPage }

func (ResearchPage) ExtractResearch

func (p ResearchPage) ExtractResearch() ogame.Researches

type ResourcesSettingsPage

type ResourcesSettingsPage struct{ FullPage }

func (ResourcesSettingsPage) ExtractResourceSettings

func (p ResourcesSettingsPage) ExtractResourceSettings() (ogame.ResourceSettings, string, error)

type RocketlayerAjaxPage

type RocketlayerAjaxPage struct{ Page }

func (RocketlayerAjaxPage) ExtractDestroyRockets

func (p RocketlayerAjaxPage) ExtractDestroyRockets() (int64, int64, string, error)

type ShipyardPage

type ShipyardPage struct{ FullPage }

func (ShipyardPage) ExtractProduction

func (p ShipyardPage) ExtractProduction() ([]ogame.Quantifiable, int64, error)

func (ShipyardPage) ExtractShips

func (p ShipyardPage) ExtractShips() (ogame.ShipsInfos, error)

type SuppliesPage

type SuppliesPage struct{ FullPage }

func (SuppliesPage) ExtractResourcesBuildings

func (p SuppliesPage) ExtractResourcesBuildings() (ogame.ResourcesBuildings, error)

Jump to

Keyboard shortcuts

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