Skip to content

Instantly share code, notes, and snippets.

@tyjeon24
Last active July 15, 2022 14:00
Show Gist options
  • Save tyjeon24/ebae6a59f11822acdf8fb1a40fb24247 to your computer and use it in GitHub Desktop.
Save tyjeon24/ebae6a59f11822acdf8fb1a40fb24247 to your computer and use it in GitHub Desktop.
Python:Selenium opera with vpn
# 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