# Use a proxy with Selenium

Start the browser using the source IP allowlist proxy address extracted from the API and verify the export and task isolation.

Support for browser-driven account-encryption proxy pop-ups varies greatly. The server-side automation can be extracted from a fixed IPv4 source direct-connect API that has been whitelisted and then used the current returned `IP:PORT` You can't shut down the accounts. `us.zzhttp.com:7878` As the result of the extraction.

## Python Selenium

```python
import json
from urllib.request import ProxyHandler, build_opener

from selenium import webdriver

extract_url = (
    "https://api.zzhttp.com/api/v1/proxy/extract"
    "?num=1&regions=GLOBAL&protocol=http&return_type=json&lb=1"
)
with build_opener(ProxyHandler({})).open(extract_url, timeout=10) as response:
    items = json.load(response)
if not isinstance(items, list) or not items:
    raise RuntimeError("The extraction endpoint returned no usable proxy address")
proxy_host = items[0]["ip"]
proxy_port = int(items[0]["port"])

options = webdriver.ChromeOptions()
options.add_argument(
    f"--proxy-server=http://{proxy_host}:{proxy_port}"
)

driver = webdriver.Chrome(options=options)
try:
    driver.get("https://ipinfo.io/json")
    print(driver.find_element("tag name", "body").text)
finally:
    driver.quit()
```

## Prepare

- The real public IPv4 of the server running is whitelisted and enabled.
- Read from actual extract response first `ip` and figures `port`; HTTP 200 may also carry a business error object, which is that the sample will reject non-array results.
- Extract and browser run in the same source environment.

## Configuration

- The boot parameters contain only the public gateway address that is being extracted.
- The extract link or results are not written to the public log.

## Segregation

- Each task uses a separate user data directory.
- Limit the number of browsers that are launched at the same time.
- After the task is complete, shut down the drive and clear the temporary state.

## Verification

- Visit the public testing page first.
- Re-confirm and retrieve whitelists when sources change or authorizations expire.

html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}
