Last active
July 15, 2022 14:00
-
-
Save tyjeon24/ebae6a59f11822acdf8fb1a40fb24247 to your computer and use it in GitHub Desktop.
Python:Selenium opera with vpn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Before running the code... | |
# 1. Set VPN function in Opera | |
# 2. Download Opera Webdriver from https://github.com/operasoftware/operachromiumdriver/releases | |
# 3. Type about://about in Opera and get profile path and installation path. | |
# 4. Set the variables. | |
# opera_profile = r"C:\profile path" | |
# options._binary_location = r"C:\\installation path." | |
from selenium import webdriver | |
options = webdriver.ChromeOptions() | |
opera_profile = r"C:\Users\username\AppData\Roaming\Opera Software\Opera Stable" | |
options.add_argument('user-data-dir=' + opera_profile) | |
options._binary_location = r'C:\Users\username\AppData\Local\Programs\Opera\66.0.3515.103\\opera.exe' | |
driver = webdriver.Opera(executable_path=r'operadriver.exe',options=options) | |
driver.get('https://api.ipify.org/?format=json"') | |
html = driver.page_source | |
print(html) | |
driver.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment