{"id":20710003,"url":"https://github.com/oxylabs/selenium-proxy-integration-python","last_synced_at":"2025-04-23T04:48:22.201Z","repository":{"id":134336675,"uuid":"412340492","full_name":"oxylabs/selenium-proxy-integration-python","owner":"oxylabs","description":"Tutorial for integrating Oxylabs' Residential Proxies with Selenium in Python","archived":false,"fork":false,"pushed_at":"2025-02-11T12:29:48.000Z","size":41,"stargazers_count":16,"open_issues_count":3,"forks_count":9,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T22:12:06.490Z","etag":null,"topics":["antidetect-browser","github-python","proxy","proxy-list","proxy-list-github","proxy-rotator","proxy-server","proxy-site","python","python-ecommerce","python-web-crawler","residential-proxy","rotating-proxy","scraper-python","selenium","serp-api-python","socks5-proxy-list","socks5-server","web-proxy","webproxy"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oxylabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-10-01T05:31:03.000Z","updated_at":"2025-03-29T20:26:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"0df3b8a1-692c-41d0-a2af-15224fec5eaa","html_url":"https://github.com/oxylabs/selenium-proxy-integration-python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fselenium-proxy-integration-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fselenium-proxy-integration-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fselenium-proxy-integration-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fselenium-proxy-integration-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oxylabs","download_url":"https://codeload.github.com/oxylabs/selenium-proxy-integration-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250372939,"owners_count":21419722,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["antidetect-browser","github-python","proxy","proxy-list","proxy-list-github","proxy-rotator","proxy-server","proxy-site","python","python-ecommerce","python-web-crawler","residential-proxy","rotating-proxy","scraper-python","selenium","serp-api-python","socks5-proxy-list","socks5-server","web-proxy","webproxy"],"created_at":"2024-11-17T02:09:31.051Z","updated_at":"2025-04-23T04:48:22.195Z","avatar_url":"https://github.com/oxylabs.png","language":"Python","readme":"# Oxylabs’ Residential Proxies integration with Selenium in Python\r\n\r\n[![Oxylabs promo code](https://raw.githubusercontent.com/oxylabs/product-integrations/refs/heads/master/Affiliate-Universal-1090x275.png)](https://oxylabs.go2cloud.org/aff_c?offer_id=7\u0026aff_id=877\u0026url_id=112)\r\n\r\n[![](https://dcbadge.vercel.app/api/server/eWsVUJrnG5)](https://discord.gg/GbxmdGhZjq)\r\n\r\n[\u003cimg src=\"https://img.shields.io/static/v1?label=\u0026message=Python\u0026color=brightgreen\" /\u003e](https://github.com/topics/python) [\u003cimg src=\"https://img.shields.io/static/v1?label=\u0026message=Selenium\u0026color=orange\" /\u003e](https://github.com/topics/selenium) [\u003cimg src=\"https://img.shields.io/static/v1?label=\u0026message=Web-Scraping\u0026color=yellow\" /\u003e](https://github.com/topics/web-scraping) [\u003cimg src=\"https://img.shields.io/static/v1?label=\u0026message=Rotating%20Proxies\u0026color=blueviolet\" /\u003e](https://github.com/topics/rotating-proxies)\r\n\r\n## Requirements\r\n\r\nFor the integration to work, you'll need to install\r\n[Selenium Wire](https://github.com/wkeeling/selenium-wire) \r\nto extend Selenium’s Python bindings as implementing proxies\r\nthat require authentication using default Selenium module \r\ncomplicates the process too much.\r\n\r\nYou can do it using `pip` command:\r\n```bash\r\npip install selenium-wire\r\n```\r\n\r\nAnother recommended package is `webdriver-manager`. It simplifies the management\r\nof binary drivers for different browsers, so you don't need to manually download\r\na new version of a web driver after each update. Visit the \r\n[official project directory](https://pypi.org/project/webdriver-manager/) on pypi to\r\nfind out more information. \r\n\r\nYou can install the following using `pip` as well:\r\n```bash\r\npip install webdriver-manager\r\n```\r\n\r\nRequired version of Python: `Python 3.5` (or higher)\r\n\r\n## Proxy Authentication\r\n\r\nFor proxies to work, you'll need to specify your account credentials inside \r\nthe [main.py](https://github.com/oxylabs/selenium-proxy-integration/blob/main/main.py) file.\r\n\r\n```python\r\nUSERNAME = \"your_username\"\r\nPASSWORD = \"your_password\"\r\nENDPOINT = \"pr.oxylabs.io:7777\"\r\n```\r\n\r\nAdjust the `your_username` and `your_password` value fields with the username and password of \r\nyour Oxylabs account.\r\n\r\n## Testing Proxy Connection\r\n\r\nTo see if the proxy is working, try visiting [ip.oxylabs.io/location](https://ip.oxylabs.io/location) \r\nIf everything is working correctly, it will return an IP address of a proxy that you're using.\r\n\r\n## Full Code\r\n```python\r\nfrom selenium.webdriver.common.by import By\r\nfrom seleniumwire import webdriver\r\n# A package to have a chromedriver always up-to-date.\r\nfrom webdriver_manager.chrome import ChromeDriverManager\r\n\r\nUSERNAME = \"your_username\"\r\nPASSWORD = \"your_password\"\r\nENDPOINT = \"pr.oxylabs.io:7777\"\r\n\r\n\r\ndef get_chrome_proxy(user: str, password: str, endpoint: str) -\u003e dict:\r\n    wire_options = {\r\n        \"proxy\": {\r\n            \"http\": f\"http://{user}:{password}@{endpoint}\",\r\n            \"https\": f\"http://{user}:{password}@{endpoint}\",\r\n        }\r\n    }\r\n\r\n    return wire_options\r\n\r\n\r\ndef execute_driver():\r\n    options = webdriver.ChromeOptions()\r\n    options.headless = True\r\n    seleniumwire_options = {\r\n        **get_chrome_proxy(USERNAME, PASSWORD, ENDPOINT),\r\n        \"driver_path\": ChromeDriverManager().install(),\r\n    }\r\n    driver = webdriver.Chrome(\r\n        options=options,\r\n        seleniumwire_options=seleniumwire_options,\r\n    )\r\n    try:\r\n        driver.get(\"https://ip.oxylabs.io/location\")\r\n        return f'\\nYour IP is: {driver.find_element(By.CSS_SELECTOR, \"pre\").text}'\r\n    finally:\r\n        driver.quit()\r\n\r\n\r\nif __name__ == \"__main__\":\r\n    print(execute_driver())\r\n```\r\n\r\nIf you're having any trouble integrating proxies with Selenium and this guide didn't help \r\nyou - feel free to contact Oxylabs customer support at support@oxylabs.io.\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxylabs%2Fselenium-proxy-integration-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foxylabs%2Fselenium-proxy-integration-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxylabs%2Fselenium-proxy-integration-python/lists"}