actions

package
v0.0.0-...-0ef06cd Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorListEnd is an error which is returned when there are no more leads to save/scrape
	// in the given list, i.e., we have reached the end of the list.
	ErrorListEnd = errors.New("reached end of list")

	// ErrorNavButtonsNotFound is an error returned when the page navigation buttons are not found
	// on the current page.
	ErrorNavButtonsNotFound = errors.New("failed to find page navigation buttons")
)
View Source
var (
	// NewUIAnnoyance represents the dialog shown to users using the
	// updated Apollo UI.
	NewUIAnnoyance = &Annoyance{
		Name:       "New UI popup",
		Regex:      "Skip tour",
		Selector:   ".zp_p2Xqs.zp_v565m.zp_qhNxC",
		ActionFunc: simpleClick,
	}

	// PopupDialogAnnoyance represents a generic popup dialog shown at random
	// moments while using Apollo.
	PopupDialogAnnoyance = &Annoyance{
		Name:       "Dialog popups",
		Regex:      "Got it",
		Selector:   ".zp_tZMYK",
		ActionFunc: simpleClick,
	}

	// SidenavAnnoyance represents the Apollo side bar which affects scraping
	// while using the rod stealth library.
	SidenavAnnoyance = &Annoyance{
		Name:       "Sidebar",
		Selector:   "#side-nav",
		ActionFunc: func(e *rod.Element) error { return e.Remove() },
	}

	// TopBannerAnnoyance represents the banner at the top of the Apollo page which
	// sometimes appears and hinders scraping.
	TopBannerAnnoyance = &Annoyance{
		Name:       "Top banner",
		Selector:   "[data-variant=black] button[aria-label=Dismiss]",
		ActionFunc: simpleClick,
	}
)
View Source
var ErrorSecurityChallenge = errors.New("encountered a cloudflare turnstile challenge")

ErrorSecurityChallenge is returned when a Cloudflare Turnstile captcha challenge has been encountered at the time of logging in.

Functions

func ApolloLogin

func ApolloLogin(
	browser *rod.Browser,
	acc *models.Account,
	timeout time.Duration,
	stealth bool,
) (page *rod.Page, err error)

ApolloLogin is a page action that logs into apollo.io with the provided *models.Account's credentials. If arg: stealth is set to true, the resulting page will be launched in stealth mode.

func FetchCreditUsage

func FetchCreditUsage(
	page *rod.Page,
	acc *models.Account,
	timeout time.Duration,
) (credits int, refreshTime *models.Time, err error)

FetchCreditUsage is a page action that fetches credit usage information for the provided *models.Account from Apollo. This function returns the amount of credits remaining and a *models.Time value indicating when credits will be renewed.

func GoToPage

func GoToPage(page *rod.Page, pageNumber int, timeout time.Duration) error

GoToPage is a page navigation function that navigates to the specified page number on the 'People' page on Apollo. This function assumes you're on the 'People' page on Apollo.

func GrabErrorSnapshot

func GrabErrorSnapshot(page *rod.Page, acc *models.Account, errorDir string) error

GrabErrorSnapshot is a page action which grabs a screenshot and the rendered HTML of the current page and saves them in the specified directory.

func LocateList

func LocateList(page *rod.Page, listName string, timeout time.Duration) error

LocateList is a page action that navigates to the Apollo list with the provided listName.

func RemoveAnnoyance

func RemoveAnnoyance(page *rod.Page, annoyance *Annoyance, timeout time.Duration) error

RemoveAnnoyanceis a page action which searches for all available instances of the specified *Annoyance on the current page and performs the action specified by [*Annoyance.ActionFunc] for each of them.

func SaveLeads

func SaveLeads(page *rod.Page, listName string, timeout time.Duration) error

SaveLeads saves all available leads on the current page to the specified list on Apollo.

func ScrapeLeads

func ScrapeLeads(page *rod.Page, timeout time.Duration) ([]*models.Lead, error)

ScrapeLeads returns all available leads on the current page (if they are found).

Types

type Annoyance

type Annoyance struct {
	Name, Regex, Selector string
	ActionFunc            func(*rod.Element) error
}

Annoyance is represents any sort of annoyance that affects the scraping flow.

type ApolloTab

type ApolloTab string

ApolloTab represents the tabs on the Apollo 'People' page.

const (
	TotalTab  ApolloTab = "Total"
	NetNewTab ApolloTab = "Net New"
	SavedTab  ApolloTab = "Saved"
)

The names of the tabs found on the Apollo 'People' page.

func (ApolloTab) Select

func (tab ApolloTab) Select(page *rod.Page) (err error)

Select selects the given ApolloTab on the page.

type PageData

type PageData struct {
	Number, Start, End, Size, TotalSize int
	LastPage                            bool
	NavButtons                          rod.Elements
}

PageData represents all available data regarding the page number, size, etc., on the current page.

func GetPageData

func GetPageData(page *rod.Page, timeout time.Duration) (pd *PageData, err error)

GetPageData is a page action that returns a *PageData value representing all available data regarding the page number, size, etc,. This function only works on the 'People' page on Apollo. This function assumes you're on the 'People' page on Apollo.

func (*PageData) NextPage

func (pd *PageData) NextPage(page *rod.Page) error

NextPage is a method for navigating to the next available page for the given set of filters.

Jump to

Keyboard shortcuts

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