• Stars
    star
    1,104
  • Rank 42,038 (Top 0.9 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 7 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

chromedp code examples.

About chromedp examples

This folder contains a variety of code examples for working with chromedp. The godoc page contains a number of simple examples which are generally self-contained, while this repository holds more complex examples which tend to require internet access or external components.

Please note that when the chromedp package is being rewritten, these examples may break. Additionally, since these examples are written for specific websites, there is a good chance that the current selectors, etc. break after the website they are written against changes.

While every effort is made to ensure that these examples are kept up-to-date, it is expected that the examples made available here may occasionally break.

To file issues, use the chromedp's issue tracker.

Building and Running an Example

You can build and run these examples in the usual Go way:

# retrieve examples
$ go get -u -d github.com/chromedp/examples

# run example <prog>
$ go run $GOPATH/src/github.com/chromedp/examples/<prog>/main.go

# build example <prog>
$ go build -o <prog> github.com/chromedp/examples/<prog> && ./<prog>

Available Examples

The following examples are currently available:

Example Description
click use a selector to click on an element
cookie set a HTTP cookie on requests
download_file do headless file downloads
download_image do headless image downloads
emulate emulate a specific device such as an iPhone
eval evaluate javascript and retrieve the result
headers add extra HTTP headers to browser requests
keys send key events to an element
logic more complex logic beyond simple actions
pdf capture a pdf of a page
proxy authenticate a proxy server which requires authentication
remote connect to an existing Chrome DevTools instance using a remote WebSocket URL
screenshot take a screenshot of a specific element and of the entire browser viewport
submit fill out and submit a form
subtree populate and travel a subtree of the DOM
text extract text from a specific element
upload upload a file on a form
visible wait until an element is visible

Contributing

Pull Requests and contributions to this project are encouraged and greatly welcomed! The chromedp project always needs new examples, and needs talented developers (such as yourself!) to submit fixes for the existing examples when they break (for example, when a website's layout/HTML changes).