我在试着刮掉定制元素,但我做不到.我的代码在以前版本的Selify和Chrome上运行得很好,但更新后就停止工作了.我可以获得整个页面的超文本标记语言,但我无法访问我想要的自定义元素.以下是e代码:

from selenium import webdriver
from selenium.webdriver.common.by import By


driver = webdriver.Chrome()
driver.get('https://w8shippingge.com/customer-zone/')


driver.find_element(By.NAME,'login').send_keys("password")

我收到错误:

DevTools listening on ws://127.0.0.1:51742/devtools/browser/eb5109e6-3d4f-4460-bf38-e94f621d2443
Traceback (most recent call last):
  File "c:/Users/Admin/Desktop/for test.py", line 9, in <module>
    driver.find_element(By.NAME,'login').send_keys("password")
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 855, in find_element
    return self.execute(Command.FIND_ELEMENT, {
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 428, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 243, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Runtime.callFunctionOn threw exception: TypeError: JSON.stringify is not a function
    at buildError (<anonymous>:323:18)
  (Session info: chrome=113.0.5672.127)
Stacktrace:
Backtrace:
        GetHandleVerifier [0x00338893+48451]
        (No symbol) [0x002CB8A1]
        (No symbol) [0x001D5058]
        (No symbol) [0x001D8176]
        (No symbol) [0x001D9631]
        (No symbol) [0x001D96D0]
        (No symbol) [0x002000C0]
        (No symbol) [0x0020069B]
        (No symbol) [0x0022DD92]
        (No symbol) [0x0021A304]
        (No symbol) [0x0022C482]
        (No symbol) [0x0021A0B6]
        (No symbol) [0x001F7E08]
        (No symbol) [0x001F8F2D]
        GetHandleVerifier [0x00598E3A+2540266]
        GetHandleVerifier [0x005D8959+2801161]
        GetHandleVerifier [0x005D295C+2776588]
        GetHandleVerifier [0x003C2280+612144]
        (No symbol) [0x002D4F6C]
        (No symbol) [0x002D11D8]
        (No symbol) [0x002D12BB]
        (No symbol) [0x002C4857]
        BaseThreadInitThunk [0x76000419+25]
        RtlGetAppContainerNamedObjectPath [0x77C3662D+237]
        RtlGetAppContainerNamedObjectPath [0x77C365FD+189]

我试着加time.sleep(),但没有结果,我得到了同样的错误.

推荐答案

如果你不是很清楚用Chrome,那就试着用Firefox吧.应该能行得通.

更改这一点:

driver = webdriver.Chrome()

致:

driver = webdriver.Firefox()

不过,在这个阶段,我不太确定Chrome的问题的根本原因.

Python相关问答推荐

为什么判断pd.DataFrame的值与判断pd.Series的值存在差异(如果索引中有值)?

从流程获取定期更新

在IIS中运行的FastAPI-获取权限错误:[Win错误10013]试图以其访问权限禁止的方式访问插槽

使用Python从HTTP打印值

在Python中添加期货之间的延迟

customtkinter中使用的这个小部件的名称是什么

覆盖Django rest响应,仅返回PK

Pandas :多索引组

GL pygame无法让缓冲区与vertextPointer和colorPointer一起可靠地工作

如何记录脚本输出

管道冻结和管道卸载

在Python中管理打开对话框

Julia CSV for Python中的等效性Pandas index_col参数

Telethon加入私有频道

当从Docker的--env-file参数读取Python中的环境变量时,每个\n都会添加一个\'.如何没有额外的?

在pandas中使用group_by,但有条件

python中字符串的条件替换

为一个组的每个子组绘制,

Matplotlib中的字体权重

Python避免mypy在相互引用中从另一个类重定义类时失败