Created
October 3, 2020 09:23
-
-
Save InJeCTrL/0697e19dd2b7c3bf0c216fccbe091126 to your computer and use it in GitHub Desktop.
雨课堂网课视频
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
import time | |
url_course = "https://grsbupt.yuketang.cn/pro/lms/84eubUXLHEy/4842006/video/{0}" | |
ff = webdriver.Firefox() | |
ff.maximize_window() | |
time.sleep(10) | |
for i in range(7117140, 7117151, 1): | |
print(i) | |
ff.get(url_course.format(str(i))) | |
while True: | |
time.sleep(3) | |
try: | |
video = ff.find_element_by_class_name("xt_video_player") | |
paused = ff.execute_script("return arguments[0].paused;", video) | |
if paused: | |
ff.find_element_by_class_name("xt_video_player_big_play_layer.pause_show").click() | |
now = ff.execute_script("return arguments[0].currentTime;", video) | |
total = ff.execute_script("return arguments[0].duration;", video) | |
delta = total - now | |
if delta <= 10: | |
break | |
except Exception as e: | |
print(e) | |
if str(e).find("xt_video_player") != -1: | |
break | |
continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment