I am trying to login to fedex.com to pull a specific cookie value for my package tracker bot. Unfortunately it looks like they have started detecting if I am performing automated actions via Selenium Chrome.
My code is:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as wait
from selenium.webdriver.support import expected_conditions as EC
options = webdriver.ChromeOptions()
options.add_argument('--no-sandbox')
options.add_argument('--headless')
options.add_argument('--disable-dev-shm-usage')
options.add_argument("--window-size=1280,1000")
options.add_argument('--disable-blink-features=AutomationControlled')
options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('excludeSwitches', ['enable-logging'])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Remote("http://127.0.0.1:4444/wd/hub", options=options)
with driver:
driver.get("https://www.fedex.com/secure-login/en-us/#/login-credentials")
wait(driver, 4).until(EC.presence_of_element_located((By.ID, 'userId')))
driver.find_element(By.ID,"userId").send_keys('USERNAME')
driver.find_element(By.ID,"password").send_keys('PASSWORD')
driver.find_element(By.ID,"login-btn").click()
But this returns a 403 page saying I do not have permission to access the page.
I have replaced all instances of cdc_ to XXX_ in the chromedriver binary. I also used driver.execute_script() to run runBotDetection() from here and it returned false.
Is there a way to bypass this?