硒:访问被拒绝

编程入门 行业动态 更新时间:2024-10-26 21:36:36
本文介绍了硒:访问被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用Selenium从LV网站中抓取一些数据,并在单击登录"按钮后继续显示拒绝访问"屏幕.我觉得这是可以防止的,因为当我手动执行相同的操作时,一切似乎都可以正常工作.奇怪的是,我需要单击两次登录"按钮才能手动登录.

I am trying to scrape some data from LV website with Selenium and keep getting 'Access Denied' screen once 'sign in' button clicked. I feel like there is a protection against this because all seems to be working fine when I do the same manually. Oddly, I need to click 'sign in' button twice to be able to sign in manually.

我的代码:

from selenium import webdriver from selenium.webdrivermon.by import By from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait options = webdriver.ChromeOptions() options.add_argument("start-maximized") options.add_experimental_option("excludeSwitches", ["enable-automation"]) options.add_experimental_option('useAutomationExtension', False) driver = webdriver.Chrome(options=options, executable_path=r'chromedriver.exe') driver.get('secure.louisvuitton/eng-gb/mylv') WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, "//span[@class='ucm-wrapper']"))) driver.find_element_by_xpath("//button[@class='ucm-button ucm-button--default ucm-choice__yes']").click() driver.find_element_by_id('loginloginForm').send_keys('xxx@xxx') driver.find_element_by_id ('passwordloginForm').send_keys('xxxxxx') driver.find_element_by_id('loginSubmit_').click()

错误:

You don't have permission to access "secure.louisvuitton/eng-gb/mylv;jsessionid=xxxxxxx.front61-prd?" on this server.

是否可以使用Selenium登录并绕过此方法?

Is there a way to login with Selenium and bypass this?

推荐答案

自从我发布此问题已经有一段时间了,但是下面是否有兴趣的人是我解决​​该问题的步骤.

It's been a while since I had posted this question but if anyone is interested below are the steps I've taken to solve the problem.

  • 在十六进制编辑器中打开 chromedriver.exe ,找到字符串 $ cdc 并替换为其他相同长度的内容.然后保存并运行修改后的二进制文件.在此答案及其答复中了解更多信息.

  • Open chromedriver.exe in hex editor, find the string $cdc and replace with something else of the same length. Then save and run modified binary. Read more in this answer and the replies to it.

    硒python代码:

    options = webdriver.ChromeOptions() options.add_argument("start-maximized") options.add_argument('--disable-blink-features=AutomationControlled') options.add_experimental_option("excludeSwitches", ["enable-automation"]) options.add_experimental_option('useAutomationExtension', False) driver = webdriver.Chrome(options=options, executable_path='chromedriver.exe') driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})") driver.execute_cdp_cmd('Network.setUserAgentOverride', {"userAgent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) ' 'AppleWebKit/537.36 (KHTML, like Gecko) ' 'Chrome/85.0.4183.102 Safari/537.36'})
  • 更多推荐

    硒:访问被拒绝

    本文发布于:2023-10-13 00:32:38,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1486300.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:被拒

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!