selenium输入框中输入内容再自动点击回车

from selenium import webdriver
    browser = webdriver.Chrome()
    browser.get('https://www.google.com')

    # 定位输入框
    input_box = browser.find_element("id", 'APjFqb')
    # 输入关键词:selenium
    input_box.send_keys('美容')
    # 模拟回车操作
    try:
        input_box.submit()
        print('成功回车')
        time.sleep(10)
        page = browser.page_source
        print(page)
    except Exception as e:
        print(e)
        print('fail')

参考:https://www.cnblogs.com/xiao-xue-di/p/11531905.html

posted @ 2023-11-07 16:47  bitterteaer  阅读(329)  评论(0编辑  收藏  举报