I‘m trying to web scrape a table with Selenium but a proxy authentication window always appears

Viewed 46

Is there a simple solution in Python to automatically put in my authentication information like username and password before scraping the site?

The proxy window looks like this:

enter image description here

2 Answers

Simple answer would be to use pyautogui

import pyautogui

class WS: 
    def __init__(self, driver_path):
        self.driver = webdriver.Chrome(driver_path)

    def enter_proxy_auth(self, proxy_username, proxy_password):
        pyautogui.typewrite(proxy_username)
        pyautogui.press('tab')
        pyautogui.typewrite(proxy_password)
        pyautogui.press('enter')
    
    
    def open_page(self, url):
        self.driver.get(url)

With pyautogui you can just fill in the username and password.

    proxy_username = 'USERNAME'
    proxy_password = 'PASSWORD'
    driver_path = 'C:/... /chromedriver.exe'
    url = 'https://...'
    
    
w = WS(driver_path)
w.open_page(url)
w.enter_proxy_auth(proxy_username, proxy_password)
email = driver.find_element_by_id("input_1")

email.send_keys("your_id")

here input_1 is tag and your_id is your email

and same will work for password also.

Related