Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 75e9bdc

Browse files
author
Paulius Gerve
committed
fix example code to support newer seleniumwire versions
1 parent c9ae937 commit 75e9bdc

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

‎README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ PASSWORD = "your_password"
6262
ENDPOINT = "pr.oxylabs.io:7777"
6363

6464

65-
def chrome_proxy(user: str, password: str, endpoint: str) -> dict:
65+
def get_chrome_proxy(user: str, password: str, endpoint: str) -> dict:
6666
wire_options = {
6767
"proxy": {
6868
"http": f"http://{user}:{password}@{endpoint}",
@@ -76,9 +76,13 @@ def chrome_proxy(user: str, password: str, endpoint: str) -> dict:
7676
def execute_driver():
7777
options = webdriver.ChromeOptions()
7878
options.headless = True
79-
proxies = chrome_proxy(USERNAME, PASSWORD, ENDPOINT)
79+
seleniumwire_options = {
80+
**get_chrome_proxy(USERNAME, PASSWORD, ENDPOINT),
81+
"driver_path": ChromeDriverManager().install(),
82+
}
8083
driver = webdriver.Chrome(
81-
ChromeDriverManager().install(), options=options, seleniumwire_options=proxies
84+
options=options,
85+
seleniumwire_options=seleniumwire_options,
8286
)
8387
try:
8488
driver.get("https://ip.oxylabs.io/")

‎main.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
ENDPOINT = "pr.oxylabs.io:7777"
99

1010

11-
def chrome_proxy(user: str, password: str, endpoint: str) -> dict:
11+
def get_chrome_proxy(user: str, password: str, endpoint: str) -> dict:
1212
wire_options = {
1313
"proxy": {
1414
"http": f"http://{user}:{password}@{endpoint}",
@@ -22,9 +22,13 @@ def chrome_proxy(user: str, password: str, endpoint: str) -> dict:
2222
def execute_driver():
2323
options = webdriver.ChromeOptions()
2424
options.headless = True
25-
proxies = chrome_proxy(USERNAME, PASSWORD, ENDPOINT)
25+
seleniumwire_options = {
26+
**get_chrome_proxy(USERNAME, PASSWORD, ENDPOINT),
27+
"driver_path": ChromeDriverManager().install(),
28+
}
2629
driver = webdriver.Chrome(
27-
ChromeDriverManager().install(), options=options, seleniumwire_options=proxies
30+
options=options,
31+
seleniumwire_options=seleniumwire_options,
2832
)
2933
try:
3034
driver.get("https://ip.oxylabs.io/")

‎requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
webdriver-manager
2-
selenium-wire
1+
webdriver-manager>=4.0.1
2+
selenium-wire>=5.1.0

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /