87e8f33b01
Normaliza lang: typescript → ts en funciones frontend y corrige file_path de functions/infra/ → functions/browser/ en funciones CDP. Actualiza referencias cn_typescript_core → cn_ts_core. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
37 lines
1.2 KiB
Markdown
37 lines
1.2 KiB
Markdown
---
|
|
name: cdp_get_html
|
|
kind: function
|
|
lang: go
|
|
domain: browser
|
|
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_browser, cdp_evaluate_go_browser]
|
|
uses_types: []
|
|
returns: []
|
|
returns_optional: false
|
|
error_type: "error_go_core"
|
|
imports: [fmt]
|
|
tested: true
|
|
tests: ["TestCdpGetHTML"]
|
|
test_file_path: "functions/browser/chrome_launch_test.go"
|
|
file_path: "functions/browser/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.
|