parser

package
v0.0.0-...-5ce5ac0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: MIT Imports: 8 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 AllianceOverviewTabAjaxPage

type AllianceOverviewTabAjaxPage struct{ Page }

func (*AllianceOverviewTabAjaxPage) ExtractAllianceClass

func (p *AllianceOverviewTabAjaxPage) ExtractAllianceClass() (ogame.AllianceClass, error)

type AllianceOverviewTabRes

type AllianceOverviewTabRes struct {
	Target  string `json:"target"`
	Content struct {
		AllianceAllianceOverview string `json:"alliance/alliance_overview"`
	} `json:"content"`
	Files struct {
		Js  []string `json:"js"`
		CSS []string `json:"css"`
	} `json:"files"`
	Page struct {
		StateObj string `json:"stateObj"`
		Title    string `json:"title"`
		URL      string `json:"url"`
	} `json:"page"`
	ServerTime   int    `json:"serverTime"`
	NewAjaxToken string `json:"newAjaxToken"`
}

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 FleetDispatchPage

type FleetDispatchPage struct{ FullPage }

func (*FleetDispatchPage) ExtractAcsValues

func (p *FleetDispatchPage) ExtractAcsValues() []ogame.ACSValues

func (*FleetDispatchPage) ExtractShips

func (p *FleetDispatchPage) ExtractShips() (ogame.ShipsInfos, error)

func (*FleetDispatchPage) ExtractSlots

func (p *FleetDispatchPage) ExtractSlots() (ogame.Slots, error)

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) ExtractColonies

func (p *FullPage) ExtractColonies() (int64, int64)

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) ExtractLifeformTypeFromDoc

func (p *FullPage) ExtractLifeformTypeFromDoc() ogame.LifeformType

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) ExtractPlanetCoordinate

func (p *FullPage) ExtractPlanetCoordinate() (ogame.Coordinate, error)

func (*FullPage) ExtractPlanetID

func (p *FullPage) ExtractPlanetID() (ogame.CelestialID, error)

func (*FullPage) ExtractPlanets

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

func (*FullPage) ExtractResources

func (p *FullPage) ExtractResources() ogame.Resources

func (*FullPage) ExtractServerTime

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

func (*FullPage) ExtractTechnocrat

func (p *FullPage) ExtractTechnocrat() bool

func (*FullPage) ExtractToken

func (p *FullPage) ExtractToken() (string, error)

type IFullPage

type IFullPage interface {
	ExtractLifeformTypeFromDoc() ogame.LifeformType
	ExtractOGameSession() string
	ExtractIsInVacation() bool
	ExtractPlanets() []ogame.Planet
	ExtractPlanetID() (ogame.CelestialID, error)
	ExtractPlanetCoordinate() (ogame.Coordinate, error)
	ExtractAjaxChatToken() (string, error)
	ExtractToken() (string, error)
	ExtractCharacterClass() (ogame.CharacterClass, error)
	ExtractCommander() bool
	ExtractAdmiral() bool
	ExtractEngineer() bool
	ExtractGeologist() bool
	ExtractTechnocrat() bool
	ExtractColonies() (int64, int64)
	ExtractServerTime() (time.Time, error)
	ExtractResources() ogame.Resources
}

func AutoParseFullPage

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

type JumpGateAjaxPage

type JumpGateAjaxPage struct{ Page }

func (*JumpGateAjaxPage) ExtractJumpGate

func (p *JumpGateAjaxPage) ExtractJumpGate() (ogame.ShipsInfos, string, []ogame.MoonID, int64)

type LfBonusesPage

type LfBonusesPage struct{ FullPage }

func (*LfBonusesPage) ExtractLfBonuses

func (p *LfBonusesPage) ExtractLfBonuses() (ogame.LfBonuses, error)

type LfBuildingsPage

type LfBuildingsPage struct{ FullPage }

func (*LfBuildingsPage) ExtractLfBuildings

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

type LfResearchPage

type LfResearchPage struct{ FullPage }

func (*LfResearchPage) ExtractArtefacts

func (p *LfResearchPage) ExtractArtefacts() (int64, int64)

func (*LfResearchPage) ExtractLfResearch

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

func (*LfResearchPage) ExtractLfSlots

func (p *LfResearchPage) ExtractLfSlots() [18]ogame.LfSlot

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, error)

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

func (*Page) SetExtractor

func (p *Page) SetExtractor(ext extractor.Extractor)

type PhalanxAjaxPage

type PhalanxAjaxPage struct{ Page }

func (*PhalanxAjaxPage) ExtractPhalanx

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

func (*PhalanxAjaxPage) ExtractPhalanxNewToken

func (p *PhalanxAjaxPage) ExtractPhalanxNewToken() (string, 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