|
@@ -0,0 +1,27 @@
|
|
|
+# Author renyupeng
|
|
|
+# coding=utf-8
|
|
|
+# @Time : 2023/6/16 下午1:02
|
|
|
+# @Site :
|
|
|
+# @File : selenium.py
|
|
|
+# @Software: PyCharm
|
|
|
+# @contact: renyupeng@c-top.com.cn
|
|
|
+# @Tel 1501435553
|
|
|
+import os
|
|
|
+import time
|
|
|
+
|
|
|
+from selenium import webdriver
|
|
|
+from selenium.webdriver.common.by import By
|
|
|
+class selenium:
|
|
|
+ @staticmethod
|
|
|
+ def SeleniumHander(url):
|
|
|
+ browser = webdriver.Chrome()
|
|
|
+ print('此时的文件路径为:' + url) # 打印此时的文件路径,所以如果文件位置固定,可以直接写url = r'文件路径'
|
|
|
+ browser.get(url) # 访问网址
|
|
|
+ huakuai = browser.find_element(by=By.XPATH, value='//*[@id="code-box"]/span') # 获取滑块按钮
|
|
|
+
|
|
|
+ action = webdriver.ActionChains(browser) # 启动滑动功能
|
|
|
+ action.click_and_hold(huakuai).perform() # 按住滑块
|
|
|
+ time.sleep(2) # 休息两秒,来看效果,不然执行太快了
|
|
|
+ action.move_by_offset(260, 0) # 移动滑块
|
|
|
+ action.release().perform()
|
|
|
+
|