Blacktraffic.AgentBrowserPuppeteer

Blacktraffic.AgentBrowser. Blacktraffic.AgentBrowserPuppeteer

Refer to Blacktraffic.AgentBrowser for methods or fields inherited from automatic destructuring.

Creates a new Puppeteer browser agent (Chrome) used for scraping tasks and purposes. Requires npm puppeteer.

Constructor:
  • arg0_key=Class.generateRandomID(Blacktraffic.AgentBrowserPuppeteer): string - The key to use for the given browser agent. Used for ID.
  • arg1_options: Object
    • .chrome_binary_path: string
    • .debug_console=false: boolean
    • .debugging_port=0: number
    • .headless=false: boolean
    • .onload: function
    • .user_data_folder: string - Refers to a Chrome profile necessary for spoofing.
    • .connection_attempts_threshold=3: number - The number of connection attempts to use when opening the browser.
    • .log_channel="console": string
    • .unique_ports=false: boolean
Instance:
Methods:
Static Fields:

Constructor

new Blacktraffic.AgentBrowserPuppeteer()

Source:

Extends

Members

Methods

(async) captureConsoleToChannel(arg0_tab_key, arg1_channel_key) → {Promise.<void>}

Captures the current tab's console and feeds it into a log.Channel.

Source:
Parameters:
Name Type Description
arg0_tab_key Object | string
arg1_channel_key string
Returns:
Type:
Promise.<void>

(async) closeTab(arg0_tab_key) → {Promise.<Blacktraffic.AgentBrowserPuppeteer>}

Closes the tab specified.

Source:
Parameters:
Name Type Description
arg0_tab_key Object | string
Returns:
Type:
Promise.<Blacktraffic.AgentBrowserPuppeteer>

(async) closeUserTabs() → {Promise.<Blacktraffic.AgentBrowserPuppeteer>}

Closes all user tabs from the current browser.

Source:
Returns:
Type:
Promise.<Blacktraffic.AgentBrowserPuppeteer>

(async) focusTab(arg0_tab_key) → {Promise.<(Object|undefined)>}

Focuses the specified tab.

Source:
Parameters:
Name Type Description
arg0_tab_key Object | string
Returns:
Type:
Promise.<(Object|undefined)>

(async) getElement(arg0_tab_key, arg1_selector, arg2_optionsopt) → {Promise.<HTMLElement>}

Fetches a specific element handle using CSS selectors.

Source:
Parameters:
Name Type Attributes Description
arg0_tab_key Object | string
arg1_selector string
arg2_options Object <optional>
Name Type Attributes Default Description
timeout number <optional>
10000
Returns:
Type:
Promise.<HTMLElement>

getTab(arg0_tab_key) → {Object}

Returns a tab object based on its key.

Source:
Parameters:
Name Type Description
arg0_tab_key Object | string
Returns:
Type:
Object

(async) getTabs() → {Promise.<Array.<Object>>}

Returns all tabs in the current browser.

Source:
Returns:
Type:
Promise.<Array.<Object>>

(async) injectScript(arg0_tab_key, arg1_function, arg2_optionsopt) → {Promise.<Object>}

Injects a script within the current tab. Note. Contexts are fully isolated when passing a function.

Source:
Parameters:
Name Type Attributes Description
arg0_tab_key string
arg1_function function
arg2_options Object <optional>
Name Type Attributes Description
options Object <optional>

Any options to pass down to the local function.

Returns:
Type:
Promise.<Object>

(async) injectScriptOnload(arg0_tab_key, arg1_function, arg2_optionsopt) → {Promise.<Object>}

Registers an onload script for future page visits using the mounted tab. Note. Contexts are fully isolated when passing a function.

Source:
Parameters:
Name Type Attributes Description
arg0_tab_key Object | string
arg1_function function
arg2_options Object <optional>
Name Type Attributes Description
options Object <optional>

Any options to pass down to the local function.

url string <optional>
Returns:
Type:
Promise.<Object>

(async) open() → {Promise.<Blacktraffic.AgentBrowserPuppeteer>}

Initialises a Chrome instance and connects Puppeteer.

Source:
Returns:
Type:
Promise.<Blacktraffic.AgentBrowserPuppeteer>

(async) openTab(arg0_tab_keyopt, arg1_url) → {Promise.<Object>}

Opens a tab at the corresponding URL. Corresponding URLs are optional.

Source:
Parameters:
Name Type Attributes Default Description
arg0_tab_key string <optional>
Object.generateRandomID(this.tab_obj)
arg1_url string
Returns:
Type:
Promise.<Object>

(async) reloadTab(arg0_tab_key) → {Promise.<Object>}

Reloads the given tab.

Source:
Parameters:
Name Type Description
arg0_tab_key string
Returns:
Type:
Promise.<Object>

(async) screenshotHTML(arg0_tab_key, arg1_path, arg2_optionsopt)

Takes multi-page or full-page screenshots from a Puppeteer instance. A4 page format by default, hence strange px values.

Source:
Parameters:
Name Type Attributes Description
arg0_tab_key Object
arg1_path string
arg2_options Object <optional>
Name Type Attributes Default Description
full_page boolean <optional>
false
height number <optional>
794
width number <optional>
1531
margin_bottom number <optional>
20

(async) tabExists(arg0_tab_key, arg1_optionsopt) → {Promise.<boolean>}

Checks if a given tab exists.

Source:
Parameters:
Name Type Attributes Description
arg0_tab_key Object | string
arg1_options Object <optional>
Name Type Attributes Default Description
strict boolean <optional>
false

Whether to also ensure the current tab is connected.

Returns:
Type:
Promise.<boolean>

updateLogChannel(arg0_channel_key)

Updates the default logging channel for the current agent.

Source:
Parameters:
Name Type Description
arg0_channel_key string

(async) waitForStableContent(arg0_tab_key, arg1_selector, arg2_intervalopt)

Waits for content to stop changing within a selector.

Source:
Parameters:
Name Type Attributes Default Description
arg0_tab_key Object | string

The given tab key.

arg1_selector string
arg2_interval number <optional>
3000