{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/pt/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Exemplos de perfis de navegador","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"exemplos-de-perfis-de-navegador","__idx":0},"children":["Exemplos de perfis de navegador"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Exemplos completos de trabalho para automação de perfil de navegador usando a API Local."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["URL base"]},": ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["http://127.0.0.1:40000"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"fluxo-de-trabalho-completo-criar--iniciar--automatizar--parar","__idx":1},"children":["Fluxo de trabalho completo: Criar → Iniciar → Automatizar → Parar"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"enrolar","__idx":2},"children":["enrolar"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"# 1. Create a browser profile\ncurl -X POST http://127.0.0.1:40000/api/env/create/quick \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\": \"my-profile\"}'\n\n# Response: {\"code\":0,\"data\":{\"envId\":\"1234567890\"}}\n\n# 2. Start the profile\ncurl -X POST http://127.0.0.1:40000/api/env/start \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"envId\": \"1234567890\"}'\n\n# Response includes debugPort and webdriver path for automation\n\n# 3. Stop the profile\ncurl -X POST http://127.0.0.1:40000/api/env/close \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"envId\": \"1234567890\"}'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"python-solicitações--selênio","__idx":3},"children":["Python (solicitações + selênio)"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import requests\nfrom selenium import webdriver\nfrom selenium.webdriver.chrome.options import Options\nfrom selenium.webdriver.chrome.service import Service\n\nBASE = \"http://127.0.0.1:40000\"\n\n# 1. Create a browser profile\nresp = requests.post(f\"{BASE}/api/env/create/quick\", json={\n    \"name\": \"automation-profile\"\n})\nenv_id = resp.json()[\"data\"][\"envId\"]\nprint(f\"Created profile: {env_id}\")\n\n# 2. Start the profile\nresp = requests.post(f\"{BASE}/api/env/start\", json={\n    \"envId\": env_id\n})\ndata = resp.json()[\"data\"]\ndebug_port = data[\"debugPort\"]\nwebdriver_path = data[\"webdriver\"]\nprint(f\"Debug port: {debug_port}, WebDriver: {webdriver_path}\")\n\n# 3. Connect Selenium\noptions = Options()\noptions.debugger_address = f\"127.0.0.1:{debug_port}\"\nservice = Service(executable_path=webdriver_path)\ndriver = webdriver.Chrome(service=service, options=options)\n\n# 4. Automate\ndriver.get(\"https://www.google.com\")\nprint(f\"Page title: {driver.title}\")\n\n# 5. Cleanup\ndriver.quit()\nrequests.post(f\"{BASE}/api/env/close\", json={\"envId\": env_id})\nprint(\"Profile closed.\")\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"nodejs-axios--titereiro","__idx":4},"children":["Node.js (axios + titereiro)"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const axios = require('axios');\nconst puppeteer = require('puppeteer');\n\nconst BASE = 'http://127.0.0.1:40000';\n\nasync function main() {\n  // 1. Create a browser profile\n  const createResp = await axios.post(`${BASE}/api/env/create/quick`, {\n    name: 'automation-profile'\n  });\n  const envId = createResp.data.data.envId;\n  console.log(`Created profile: ${envId}`);\n\n  // 2. Start the profile\n  const startResp = await axios.post(`${BASE}/api/env/start`, {\n    envId: envId\n  });\n  const { debugPort } = startResp.data.data;\n  console.log(`Debug port: ${debugPort}`);\n\n  // 3. Connect Puppeteer\n  const browser = await puppeteer.connect({\n    browserWSEndpoint: `ws://127.0.0.1:${debugPort}`,\n    defaultViewport: null\n  });\n\n  // 4. Automate\n  const page = await browser.newPage();\n  await page.goto('https://www.google.com');\n  console.log(`Page title: ${await page.title()}`);\n\n  // 5. Cleanup\n  await browser.disconnect();\n  await axios.post(`${BASE}/api/env/close`, { envId });\n  console.log('Profile closed.');\n}\n\nmain().catch(console.error);\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"operações-em-lote","__idx":5},"children":["Operações em lote"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"proxy-de-atualização-em-lote-python","__idx":6},"children":["Proxy de atualização em lote (Python)"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import requests\n\nBASE = \"http://127.0.0.1:40000\"\n\n# Get all profile IDs\nresp = requests.post(f\"{BASE}/api/env/page\", json={\n    \"pageNo\": 1, \"pageSize\": 100\n})\nenv_ids = [p[\"envId\"] for p in resp.json()[\"data\"][\"dataList\"]]\n\n# Batch update proxy for all profiles\nrequests.post(f\"{BASE}/api/env/updateProxy/batch\", json={\n    \"envDataList\": [\n        {\n            \"envId\": env_id,\n            \"proxyInfo\": {\n                \"proxyType\": \"socks5\",\n                \"host\": \"proxy.example.com\",\n                \"port\": 1080,\n                \"proxyUserName\": \"user\",\n                \"proxyPassword\": \"pass\"\n            }\n        }\n        for env_id in env_ids\n    ]\n})\nprint(f\"Updated proxy for {len(env_ids)} profiles.\")\n","lang":"python"},"children":[]}]},"headings":[{"value":"Exemplos de perfis de navegador","id":"exemplos-de-perfis-de-navegador","depth":1},{"value":"Fluxo de trabalho completo: Criar → Iniciar → Automatizar → Parar","id":"fluxo-de-trabalho-completo-criar--iniciar--automatizar--parar","depth":2},{"value":"enrolar","id":"enrolar","depth":3},{"value":"Python (solicitações + selênio)","id":"python-solicitações--selênio","depth":3},{"value":"Node.js (axios + titereiro)","id":"nodejs-axios--titereiro","depth":3},{"value":"Operações em lote","id":"operações-em-lote","depth":2},{"value":"Proxy de atualização em lote (Python)","id":"proxy-de-atualização-em-lote-python","depth":3}],"frontmatter":{"seo":{"title":"Exemplos de perfis de navegador"}},"lastModified":"2026-06-10T11:47:34.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/pt/api-reference/examples/browser-examples","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}