chromedpproxy

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2023 License: MPL-2.0 Imports: 14 Imported by: 0

README

ChromeDP Proxy

Go ChromeDPProxy

Inspired by claabs/puppeteer-extra-plugin-portal

A Go module for a ChromeDP abstraction layer that additionally hosts a webserver to remotely view ChromeDP sessions. Essentially opening a "portal" to the page. Perfect for Go automations that require manual intervention.

IMPORTANT: You must install xvfb on the system / docker container

Report Bugs · Request Features

About The Project

Built With
Examples

Please proceed to the examples directory

Getting Started

Installing
go get github.com/jarylc/go-chromedpproxy
Usage
Basic
// step 1 - prepare proxy
// change `:9222` to your desired Chrome remote debugging port
// change `:9221` to your desired webserver port for the front-end
// append and/or remove `chromedp.DisableGPU` with your desired allocated executor options as additional arguments
chromedpproxy.PrepareProxy(":9222", ":9221", chromedp.DisableGPU)

// step 2 - launch a tab target
// append and/or remove `chromedp.WithLogf(log.Printf)` with your desired context options as additional arguments
targetID, err := chromedpproxy.NewTab("https://www.google.com/recaptcha/api2/demo", chromedp.WithLogf(log.Printf))
if err != nil && !errors.Is(err, context.Canceled) {
    log.Fatal(err)
}
defer chromedpproxy.CloseTarget(targetID)

// step 3 - get context and do whatever you need, you can refer to the examples directory of the project
ctx := chromedpproxy.GetTarget(targetID)
// ...
ChromeDP

Please refer to chromedp/chromedp repository for general chromedp usage

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Feel free to fork the repository and submit pull requests.

License

Distributed under the GNU GENERAL PUBLIC LICENSE V3. See LICENSE for more information.

Contact

Jaryl Chng - git@jarylchng.com

https://jarylchng.com

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseTarget

func CloseTarget(id target.ID) error

CloseTarget closes a target by closing the page if the last page has been closed, clean up everything it returns an error if any

func GetTarget

func GetTarget(id target.ID) context.Context

GetTarget returns a context from a target ID

func NewTab

func NewTab(url string, customOpts ...chromedp.ContextOption) (target.ID, error)

NewTab abstracts creating a new tab in the root context it returns a target ID or error

func PrepareProxy

func PrepareProxy(chromeListenAddr string, frontendListenAddr string, customOpts ...chromedp.ExecAllocatorOption)

PrepareProxy abstracts chromedp.NewExecAllocator to the use case of this package it accepts listen addresses for both Chrome remote debugging and frontend as configuration it is also a variadic function that accepts extra chromedp.ExecAllocatorOption to be passed to the chromedp.NewExecAllocator

Types

This section is empty.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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