不是 puppeteer !
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 occassionally break.
To file issues, use the chromedp's issue tracker.
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>
The following examples are currently available:
Example | Description |
---|---|
click2 | 点击元素 use a selector to click on an element |
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 | 执行js 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 |
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 |
text2 | extract text from a specific element |
text | extract text from a specific element |
upload | 上传文件upload a file on a form |
visible | 元素可见 wait until an element is visible |
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).