0

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?

Bijan
  • 7,737
  • 18
  • 89
  • 149
  • maybe script should behave like real human and start at main page https://www.fedex.com – furas Jun 07 '22 at 03:00
  • there is module [undetected-chromedriver](https://github.com/ultrafunkamsterdam/undetected-chromedriver) which also replaces `cdc_` in binary. And it these it with page https://nowsecure.nl – furas Jun 07 '22 at 03:02
  • @furas i tried normal fedex start at had same issue. Undetected-chromedriver works but not in headless mode (which is a requirement for my server) – Bijan Jun 07 '22 at 07:54
  • do you mean undetected-chromedriver resolves problem with error 403? Maybe problem is only modifiaction in driver. undetected-chromedriver downlads driver, makes modification and keeps it somewhere on disk. Maybe you could find this driver and use with your code. – furas Jun 07 '22 at 10:37
  • @furas when i use headless mode, even undetected chromedriver doesn't work. – Bijan Jun 07 '22 at 12:47
  • and if you DON'T use `headless mode` then has `undetected chromedriver` problem with error 403? It could help to see if `undetected chromedriver` can helps to resolve problem with 403. Maybe you could copy binary driver from `undetected chromedriver` to your code. – furas Jun 07 '22 at 13:04
  • @furas when not headless, uc works. Their github states that headless is still a WIP – Bijan Jun 07 '22 at 16:43
  • does this mean that with UC you don't have problem with error 403? maybe it needs to digg in its source code and get its idea to own code. maybe UC changes `cdc_` in better way. – furas Jun 07 '22 at 17:02
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/245395/discussion-between-bijan-and-furas). – Bijan Jun 07 '22 at 17:28

0 Answers0