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:
@@ -0,0 +1,20 @@
|
||||
package infra
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// CdpGetHTML retorna el HTML completo de la pagina actual (document.documentElement.outerHTML).
|
||||
// Equivale a hacer "Ver codigo fuente" pero con el DOM actual (post-JavaScript).
|
||||
func CdpGetHTML(c *CDPConn) (string, error) {
|
||||
if c == nil {
|
||||
return "", fmt.Errorf("cdp get html: conexion nula")
|
||||
}
|
||||
|
||||
html, err := CdpEvaluate(c, "document.documentElement.outerHTML")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("cdp get html: %w", err)
|
||||
}
|
||||
|
||||
return html, nil
|
||||
}
|
||||
Reference in New Issue
Block a user