Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/herudi/cdv
Headless Browser in V
https://github.com/herudi/cdv
chrome devtools-protocol firefox headless-chrome headless-edge headless-firefox msedge vlang
Last synced: 4 days ago
JSON representation
Headless Browser in V
- Host: GitHub
- URL: https://github.com/herudi/cdv
- Owner: herudi
- License: mit
- Created: 2024-12-14T04:54:49.000Z (25 days ago)
- Default Branch: master
- Last Pushed: 2024-12-27T07:42:32.000Z (11 days ago)
- Last Synced: 2024-12-27T08:28:40.569Z (11 days ago)
- Topics: chrome, devtools-protocol, firefox, headless-chrome, headless-edge, headless-firefox, msedge, vlang
- Language: V
- Homepage:
- Size: 164 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CDV
Headless Browser in V.
> Status: Experimental.
> This project based on CDP spec https://chromedevtools.github.io/devtools-protocol.
## Browser Support
- Chrome/Chromium
- Edge
- Firefox
- Safari soon...
- Opera soon...## Install
```bash
v install --git https://github.com/herudi/cdv
```## Import
```v
import cdv
```## Usage
```v
mut browser := cdv.open_chrome()!
defer { browser.close() }mut page := browser.new_page()
page.user_agent('my-user-agent')
page.navigate('https://vlang.io')// code here for listen event fired before wait until page load finished.
page.on_request(fn (mut req cdv.Request) ! {
println(req)
})page.wait_until()
// code here for other method.
page.save_as_png('./vlang.png')```
## Example
this example automate fb login.
```v
mut browser := cdv.open_chrome()!
defer { browser.close() }mut page := browser.new_page()
page.navigate('https://facebook.com')
page.wait_until()mut form := page.selector('form')
form.input('#email', '[email protected]')
form.input('#pass', 'my_password')
form.click('button[type="submit"]')page.wait_until()
pathname := page.eval('window.location.pathname').str()
if pathname.starts_with('/login') {
println('login failed...')
} else {
println('login success...')
}
```## License
[MIT](LICENSE)