Documentation
¶
Index ¶
- Constants
- func CheckGreedy(tag string) (finalTag string, greedy bool)
- func ParseCurrency(format, amount string) (result float64, err error)
- func ParseDate(format, date string) (resultT time.Time, result string, err error)
- type AccountConfig
- type AccountMap
- type AccountScrapeData
- func (data *AccountScrapeData) GetCmdLine() (err error)
- func (data *AccountScrapeData) LoadSnapshot() (err error)
- func (data *AccountScrapeData) MakeHistoryReport() (err error)
- func (data *AccountScrapeData) ParseHistory() (err error)
- func (data *AccountScrapeData) ReadAccountConfigs() (err error)
- func (data *AccountScrapeData) ReadBusinessConfigs() (err error)
- func (data *AccountScrapeData) ScrapeAccount(browser Browser, id string, result chan ScrapeResult)
- func (data *AccountScrapeData) StoreTable(id string, table [][]string)
- func (data *AccountScrapeData) WriteSnapshot() (err error)
- type Browser
- func (browser *Browser) ExecuteCommands(page *ScrapePage, commands Commands, tasks *Tasks) (err error)
- func (browser *Browser) LaunchBrowser(chromium bool) (err error)
- func (browser *Browser) PrintCommands(commands Commands, indent int)
- func (browser *Browser) PushTask(page *ScrapePage, command Command, tasks *Tasks) (err error)
- func (browser *Browser) Shutdown() (err error)
- func (browser *Browser) WalkDownTable(page *ScrapePage, rowTag, colTag, linkText string, commands Commands, ...) (err error)
- type BusinessConfig
- type BusinessMap
- type CmdLine
- type Command
- type Commands
- type ErrList
- type HistoryData
- type HistoryMap
- type HistoryRow
- type SaveSettings
- type ScrapePage
- func (page *ScrapePage) GetCell(tag, line string) (err error)
- func (page *ScrapePage) GetCellWithHeading(rowTag, headTag, colTag, tHeading string) (err error)
- func (page *ScrapePage) GetList(acctLog *log.Logger, rowTag, rowAttr string) (err error)
- func (page *ScrapePage) GetTable(acctLog *log.Logger, rowTag, colTag string) (err error)
- func (page *ScrapePage) PadTableColumn(padspec string) (err error)
- func (page *ScrapePage) SplitTableColumn(sep, heading, newHeading string) (err error)
- type ScrapeResult
- type Tasks
Constants ¶
const Chromium = "/Applications/Chromium.app/Contents/MacOS/Chromium"
Variables ¶
This section is empty.
Functions ¶
func CheckGreedy ¶
func ParseCurrency ¶
Types ¶
type AccountConfig ¶
type AccountConfig struct {
AccountName string `json:"account_name"`
AccountId string `json:"account_id"`
BusinessId string `json:"business_id"`
CompactName string
Username string `json:"username"`
Password string `json:"password"`
// Account-specific Overrides (optional)
Url string `json:"url"`
DateFormat string `json:"date_format"`
CurrencyFormat string `json:"currency_format"`
AmountColumn string `json:"amount_column"`
DateColumn string `json:"date_column"`
}
Account configuration
func (AccountConfig) ParseFormats ¶
func (ac AccountConfig) ParseFormats(pd *HistoryData) (err error)
func (AccountConfig) VariableSubstitute ¶
func (ac AccountConfig) VariableSubstitute(commands Commands) (new Commands, err error)
type AccountMap ¶
type AccountMap map[string]AccountConfig
type AccountScrapeData ¶
type AccountScrapeData struct {
CmdLine CmdLine
Save SaveSettings
AccountMap AccountMap
BusinessMap BusinessMap
}
AccountScrape data - main functions are methods of this
func Begin ¶
func Begin() (data *AccountScrapeData, err error)
func NewAccountScrapeData ¶
func NewAccountScrapeData() (data *AccountScrapeData)
func (*AccountScrapeData) GetCmdLine ¶
func (data *AccountScrapeData) GetCmdLine() (err error)
func (*AccountScrapeData) LoadSnapshot ¶
func (data *AccountScrapeData) LoadSnapshot() (err error)
func (*AccountScrapeData) MakeHistoryReport ¶
func (data *AccountScrapeData) MakeHistoryReport() (err error)
func (*AccountScrapeData) ParseHistory ¶
func (data *AccountScrapeData) ParseHistory() (err error)
func (*AccountScrapeData) ReadAccountConfigs ¶
func (data *AccountScrapeData) ReadAccountConfigs() (err error)
func (*AccountScrapeData) ReadBusinessConfigs ¶
func (data *AccountScrapeData) ReadBusinessConfigs() (err error)
func (*AccountScrapeData) ScrapeAccount ¶
func (data *AccountScrapeData) ScrapeAccount(browser Browser, id string, result chan ScrapeResult)
func (*AccountScrapeData) StoreTable ¶
func (data *AccountScrapeData) StoreTable(id string, table [][]string)
func (*AccountScrapeData) WriteSnapshot ¶
func (data *AccountScrapeData) WriteSnapshot() (err error)
type Browser ¶
type Browser struct {
Cdp *chromedp.CDP
Ctxt context.Context
Cancel context.CancelFunc
Log *log.Logger
Id string
Port int
}
Browser configuration
func (*Browser) ExecuteCommands ¶
func (browser *Browser) ExecuteCommands(page *ScrapePage, commands Commands, tasks *Tasks) (err error)
Create list of tasks to execute from config file command list
func (*Browser) LaunchBrowser ¶
func (*Browser) PrintCommands ¶
func (*Browser) PushTask ¶
func (browser *Browser) PushTask(page *ScrapePage, command Command, tasks *Tasks) (err error)
func (*Browser) WalkDownTable ¶
func (browser *Browser) WalkDownTable(page *ScrapePage, rowTag, colTag, linkText string, commands Commands, indent int) (err error)
This function works only after GetTable
type BusinessConfig ¶
type BusinessConfig struct {
BusinessName string `json:"business_name"`
Login [][]string `json:"login" scrape:"Login"`
History [][]string `json:"history" scrape:"History"`
Logout [][]string `json:"logout" scrape:"Logout"`
// Default values for business
Url string `json:"url"`
DateFormat string `json:"date_format"`
CurrencyFormat string `json:"currency_format"`
AmountColumn string `json:"amount_column"`
DateColumn string `json:"date_column"`
}
Business configuration
type BusinessMap ¶
type BusinessMap map[string]BusinessConfig
type CmdLine ¶
type CmdLine struct {
Debug bool
Chromium bool
ShowTable bool
AccountIds string
RedoAccountIds string
AccountConfigDir string
BusinessConfigDir string
SnapShotFile string
Logfile string
}
Command line arguments
type HistoryData ¶
type HistoryData struct {
MinDateT time.Time
MaxDateRow int
EmptyLen int
AmountCol int
DateCol int
HistoryToMatch int
HistoryTable []HistoryRow
}
Extracted results
func (*HistoryData) IdentifyRowsToSkip ¶
func (pd *HistoryData) IdentifyRowsToSkip()
type HistoryMap ¶
type HistoryMap map[string]HistoryData
type HistoryRow ¶
type SaveSettings ¶
type SaveSettings struct {
AccountIds []string
HistoryMap HistoryMap
}
Settings that will be saved in / loaded from snapshot
type ScrapePage ¶
type ScrapePage struct {
Name string
AccountId string
Commands Commands
Tasks chromedp.Tasks
TableHtml string
Table [][]string
Heading string
TextHtml string
Text string
Flag bool
}
Scrape commands and data for a particular page (login, history, logout)
func (*ScrapePage) GetCell ¶
func (page *ScrapePage) GetCell(tag, line string) (err error)
func (*ScrapePage) GetCellWithHeading ¶
func (page *ScrapePage) GetCellWithHeading(rowTag, headTag, colTag, tHeading string) (err error)
func (*ScrapePage) GetList ¶
func (page *ScrapePage) GetList(acctLog *log.Logger, rowTag, rowAttr string) (err error)
This function is used to extract a list as a table
func (*ScrapePage) GetTable ¶
func (page *ScrapePage) GetTable(acctLog *log.Logger, rowTag, colTag string) (err error)
This function can get called twice, once for header row, then for data rows
func (*ScrapePage) PadTableColumn ¶
func (page *ScrapePage) PadTableColumn(padspec string) (err error)
This function pads for an optional column
func (*ScrapePage) SplitTableColumn ¶
func (page *ScrapePage) SplitTableColumn(sep, heading, newHeading string) (err error)
This function splits one column into two
type ScrapeResult ¶
Result of a scrape on a given account, returns via channel from go routine
