feat: funciones Chrome CDP para automatización de navegador

10 funciones Go en infra/ para controlar Chrome via Chrome DevTools Protocol:
chrome_launch, cdp_connect, cdp_navigate, cdp_evaluate, cdp_screenshot,
cdp_click, cdp_type_text, cdp_wait_element, cdp_get_html, cdp_close.
WebSocket RFC 6455 implementado sin dependencias externas.
Incluye tests de integración con Chrome real.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-29 17:30:56 +02:00
parent a4df450d41
commit 73bf619191
22 changed files with 1541 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
---
name: cdp_get_html
kind: function
lang: go
domain: infra
version: "1.0.0"
purity: impure
signature: "func CdpGetHTML(c *CDPConn) (string, error)"
description: "Retorna el HTML completo de la pagina actual (document.documentElement.outerHTML) via Runtime.evaluate. Captura el DOM vivo post-JavaScript, no el HTML fuente original."
tags: [chrome, cdp, browser, automation, html, dom, scraping, devtools]
uses_functions: [cdp_connect_go_infra, cdp_evaluate_go_infra]
uses_types: []
returns: []
returns_optional: false
error_type: "error_go_core"
imports: [fmt]
tested: true
tests: ["TestCdpGetHTML"]
test_file_path: "functions/infra/chrome_launch_test.go"
file_path: "functions/infra/cdp_get_html.go"
---
## Ejemplo
```go
conn, _ := CdpConnect(9222)
CdpNavigate(conn, "https://example.com")
CdpWaitElement(conn, "body", 5*time.Second)
html, err := CdpGetHTML(conn)
// html contiene el DOM completo con todos los cambios JS aplicados
```
## Notas
A diferencia de `Page.getResourceContent`, esta funcion captura el estado actual del DOM incluyendo modificaciones hechas por JavaScript. Ideal para scraping de SPAs (React, Vue, Angular). El HTML retornado puede ser muy largo para paginas complejas.