From 457e7ba3aa925bf44fe72ea4a6993aa02b695d5b Mon Sep 17 00:00:00 2001 From: prmzba57e <1641050300@qq.com> Date: Wed, 12 Apr 2023 20:39:36 +0800 Subject: [PATCH] ADD file via upload --- selenium模块的对搜索框的搜索.py | 39 +++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 selenium模块的对搜索框的搜索.py diff --git a/selenium模块的对搜索框的搜索.py b/selenium模块的对搜索框的搜索.py new file mode 100644 index 0000000..40de009 --- /dev/null +++ b/selenium模块的对搜索框的搜索.py @@ -0,0 +1,39 @@ + + + + + + + + + + + +#pip install selenium +#下载浏览器驱动,可以使用不同浏览器驱动进行选择 +# 定义一个输入字符串str对函数进行输入 +import time +from selenium.webdriver.common.keys import Keys + + +from selenium.webdriver import Edge + + # 引入模块 +from selenium.webdriver.common.by import By +# +# # 改写方法 +# dr.find_element(By.XPATH, "my xpath") + +web=Edge() +time.sleep(1) +web.get("https://www.qbiqu.com/") +#找到目标网页,然后找到input输入框进行输入---有两种实现模式1.输入回车2.按下搜索按钮 +time.sleep(2) +inputweb=web.find_element(By.XPATH,'//*[@id="wd"]').send_keys("冰火魔厨",Keys.ENTER) +time.sleep(2) +web.switch_to.window(web.window_handles[-1]) +#使用模块提取到目的书籍的url +url=web.current_url +# url=inputweb.current_url +print(url) +# time.sleep(100) \ No newline at end of file