breaksleep(2)wd.switch_to.frame(course_frm)sleep(1)wd.switch

回到原来的窗口wd.switch_to.window(wd.window_handles[0])#对应的是第一个窗口sleep(2)wd.get('https://www.XXX.gov.cn/student/course_myselect.do?searchType=2menu=course')sleep(2)print(i)i += 1 , /html/body/div/div[3]/div[2]).click()sleep(700)#关闭子窗口wd.close()#变更selenium窗口, '//*[@id=pwd]')elements.click()elements.send_keys ('你的密码')elements = wd.find_element(By.XPATH,通过再群里学习和找资料 找到了通过python selenium 浏览器自动学习 某省干部网络学院 方法 非必修课程课程先手动添加 程序循环自动播放 还未实现 部分FLASh页面播放 欢迎大佬帮忙完善。

//*[@id='username'])elements.click()elements.send_keys('你的账号')sleep(3)elements = wd.find_element(By.XPATH, /html/body/div[3]/a[1]).click()sleep(3)elements = wd.find_element(By.XPATH, /html/body/div[2]/div[2]/div[2]/div/div[2]/div[1]/div[2]/div[2]/input).click()#点击播放 /html/body/div/div[3]/div[2]sleep(3)for handle in wd.window_handles:# 先切换到该窗口wd.switch_to.window(handle)# 得到该窗口的标题栏字符串,谢谢! [Python] 纯文本查看 复制代码 from selenium import webdriverfrom selenium.webdriver.chrome.service import Servicefrom selenium.webdriver.common.by import By#import requestsfrom time import sleep# 创建 WebDriver 对象, 本帖最后由 xq2581 于 2023-6-8 09:52 编辑 第一次发帖,那么这时候WebDriver对象就是对应的该该窗口,跳出循环,判断是不是我们要操作的那个窗口if '播放中...' in wd.title:# 如果是, /html/body/div[2]/div/div[2]/form/div[3]/input).click()sleep(5)wd.get('https://www.XXX.gov.cn/student/course_myselect.do?searchType=2menu=course')sleep(5)#循环N次播放视频i = 1while i = 30:#点击我要学习elements = wd.find_element(By.XPATH,指明使用chrome浏览器驱动wd = webdriver.Chrome(service=Service(r'C:\Program Files\Google\Chrome\Application\chromedriver.exe'))#wd = webdriver.Chrome()# 调用WebDriver 对象的get方法 可以让浏览器打开指定网址wd.get('https://wwwXXX.gov.cn/index.html')sleep(5)elements = wd.find_element(By.XPATH。

正好,breaksleep(2)wd.switch_to.frame(course_frm)sleep(1)wd.switch_to.frame(course_frame)sleep(2)#点击“开始学习”开始播放elements = wd.find_element(By.XPATH,。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://acg.inmoke.com/zixun/Jk/55130.html