-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebsite-proxy.py
More file actions
executable file
·53 lines (40 loc) · 1.57 KB
/
website-proxy.py
File metadata and controls
executable file
·53 lines (40 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
## Website Proxy Usage
# Create and activate a virtual environment:
# python3 -m venv venv
# source venv/bin/activate (Mac/Linux)
# venv\Scripts\activate (Windows)
# Install required dependencies:
# pip3 install webdriver-manager seleniumwire
# solution (if not work)
# pip3 install --upgrade setuptools
# pip3 install blinker==1.7.0
# Run the script:
# python3 website-proxy.py
from seleniumwire import webdriver # Use SeleniumWire instead of Selenium
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
# Proxy credentials
PROXY_HOST = "xxx.xxxxxx.com" # Change this
PROXY_PORT = "XXXXX" # Change this
PROXY_USERNAME = "username" # Change this
PROXY_PASSWORD = "password" # Change this
# Selenium Wire Options (for proxy authentication)
seleniumwire_options = {
'proxy': {
'http': f'http://{PROXY_USERNAME}:{PROXY_PASSWORD}@{PROXY_HOST}:{PROXY_PORT}',
'https': f'https://{PROXY_USERNAME}:{PROXY_PASSWORD}@{PROXY_HOST}:{PROXY_PORT}',
'no_proxy': 'localhost,127.0.0.1' # Bypass local addresses
}
}
# Set Chrome options
chrome_options = Options()
chrome_options.add_argument("--start-maximized")
# Initialize WebDriver
service = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=service, options=chrome_options, seleniumwire_options=seleniumwire_options)
# Open the target website
driver.get("https://www.erkankavas.com")
input('Press ENTER to close the automated browser')
# Close the browser
driver.quit()