{"id":20710048,"url":"https://github.com/oxylabs/playwright-proxy-integration-js","last_synced_at":"2025-04-23T04:48:06.825Z","repository":{"id":44763437,"uuid":"449192940","full_name":"oxylabs/playwright-proxy-integration-js","owner":"oxylabs","description":"A tutorial for implementing Oxylabs` Residential and Datacenter proxies with Playwright using JavaScript","archived":false,"fork":false,"pushed_at":"2025-02-11T12:43:36.000Z","size":21,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-29T22:12:04.601Z","etag":null,"topics":["javascript","nodejs","playwright","playwright-java","proxies","proxy-list","proxy-list-github","proxy-rotator","proxy-site","residential-proxy","rotating-proxy","web-scraping"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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":"2022-01-18T08:01:10.000Z","updated_at":"2025-03-17T04:45:46.000Z","dependencies_parsed_at":"2023-12-18T10:53:03.508Z","dependency_job_id":null,"html_url":"https://github.com/oxylabs/playwright-proxy-integration-js","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%2Fplaywright-proxy-integration-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fplaywright-proxy-integration-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fplaywright-proxy-integration-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fplaywright-proxy-integration-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oxylabs","download_url":"https://codeload.github.com/oxylabs/playwright-proxy-integration-js/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":["javascript","nodejs","playwright","playwright-java","proxies","proxy-list","proxy-list-github","proxy-rotator","proxy-site","residential-proxy","rotating-proxy","web-scraping"],"created_at":"2024-11-17T02:09:39.815Z","updated_at":"2025-04-23T04:48:06.819Z","avatar_url":"https://github.com/oxylabs.png","language":"JavaScript","readme":"# Oxylabs' Proxy Integration with Playwright \n\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)\n\n[![](https://dcbadge.vercel.app/api/server/eWsVUJrnG5)](https://discord.gg/GbxmdGhZjq)\n\n[\u003cimg src=\"https://img.shields.io/static/v1?label=\u0026message=JavaScript\u0026color=brightgreen\" /\u003e](https://github.com/topics/javascript) [\u003cimg src=\"https://img.shields.io/static/v1?label=\u0026message=Web%20Scraping\u0026color=important\" /\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)\n- [Requirements](#requirements)\n- [Integrating Datacenter Proxies](#integrating-datacenter-proxies)\n- [Integrating Residential Proxies](#integrating-residential-proxies)\n## Requirements\n\n### Playwright\n```bash\nnpm install playwright\n```\n\n## Integrating Datacenter Proxies \n\n### Getting a List of Proxies\n\nOpen the following URL in the browser and enter your credentials. You will see a list of proxies in plain text:\n\n```\nhttps://proxy.oxylabs.io/all\n```\n\n### Using Proxies\n\nIf you wish to select any of the provided proxies, you need to save the proxy IP, along with the port, in a variable.\n\nTo use all these proxies, first, save these proxies as an array in your code:\n\n```javascript\nlet proxies = [\n    '127.0.0.1:60000',\n    '127.0.0.2:60000',\n    '127.0.0.3:60000',\n    '127.0.0.4:60000'\n  ]\n```\n\nTo select one of the proxies randomly, use the following line of code:\n\n```JavaScript\nvar proxy = proxies[Math.floor(Math.random() * proxies.length)];\n```\n\nCreate a variable called `launchOptions` and assign the proxy information to it.\n\nDon't forget to replace `USERNAME` and `PASSWORD` with your proxy user credentials.\n\n```javascript\nconst launchOptions = {\n        proxy: {\n            server: proxy,\n            username: 'USERNAME',\n            password: 'PASSWORD'\n        }\n    };\n```\n\nAfter creating the `launchOptions` variable, create a `playwright` instance and launch the browser.\n\n```javascript\nconst browser = await chromium.launch(launchOptions);\n```\n\nFor the complete code sample, see [this file](datacenter_random.js).\n\n\n## Integrating Residential Proxies\n\n### Random Proxy Using the Proxy API\nProxy information can be supplied as a parameter to the `launch` method of `playwright` instance. \n\nAlternatively, create a variable called `launchOptions` and assign the proxy information to it.\n\nDon't forget to replace `USERNAME` and `PASSWORD` with your proxy user credentials.\n\n```javascript\nconst launchOptions = {\n        proxy: {\n            server: 'pr.oxylabs.io:7777',\n            username: 'USERNAME',\n            password: 'PASSWORD'\n        },\n        headless: false\n    };\n```\n\nThe additional benefit of using lauchOptions variable is that other information such as `headless` can be supplied to the `launch` method.:\n\nAfter creating the `launchOptions` variable, create a `playwright` instance and launch the browser.\n\n```javascript\nconst browser = await chromium.launch(launchOptions);\n```\n\nFor the complete code sample, see [this file](residential_random.js).\n\n### Country Specific Proxies\n\nIf you wish to use country-specific proxies, all you need to do is change the proxy server.\n\nFor example, if you wish to use the proxy for the United States, you can use the following code:\n\n```javascript\nconst launchOptions = {\n        proxy: {\n            server: 'us-pr.oxylabs.io:10001',\n            username: 'USERNAME',\n            password: 'PASSWORD'\n        },\n        headless: false\n    };\n\n```\n\nIn this example, us-pr.oxylabs.io:10000 is the country specific entry point for the United States.\n\nAnother example is `gb-pr.oxylabs.io:20000`, which is the country specific entry point for United Kingdom.\n\nFor a complete list of all entry points, see [Country Specific Entry Nodes](https://oxy.yt/zrG0).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxylabs%2Fplaywright-proxy-integration-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foxylabs%2Fplaywright-proxy-integration-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxylabs%2Fplaywright-proxy-integration-js/lists"}