| cdp_new_tab |
function |
go |
browser |
0.1.0 |
impure |
func CdpNewTab(host string, port int, startURL string) (CdpTab, error) |
Abre una pestaña nueva via /json/new. Si startURL es vacio Chrome abre about:blank. Retorna el CdpTab recien creado con su id, webSocketDebuggerUrl, etc. Compatible con Chrome 126+ (PUT) y anteriores (fallback GET). |
|
|
|
|
false |
error_go_core |
| encoding/json |
| fmt |
| net/http |
| net/url |
|
tab, err := browser.CdpNewTab("localhost", 9222, "https://example.com")
if err == nil {
fmt.Println("nueva tab id=", tab.ID)
}
|
true |
|
functions/browser/cdp_list_tabs_test.go |
functions/browser/cdp_list_tabs.go |
- Definida en mismo archivo que CdpListTabs — comparten estructura.
- Desde Chrome 126 el endpoint requiere PUT. Mantenemos fallback a GET por compatibilidad.
- URL se codifica como query string raw (no clave=valor — formato historico de Chrome).
|
Util para abrir tabs de scraping bajo control programatico sin pasar por
WebSocket. Combina con CdpListTabs para enumerar antes/despues, y
CdpCloseTab para limpiar al final.
|
| name |
desc |
| host |
Host CDP (vacio = localhost). |
|
| name |
desc |
| port |
Puerto remote-debugging. |
|
| name |
desc |
| startURL |
URL inicial. Vacio = about:blank. |
|
|
CdpTab del target recien creado (id, websocket url, ...). Error si HTTP falla. |