From 1d4fb4981f89aa1701810b819b5a9bfacf4407aa Mon Sep 17 00:00:00 2001 From: msglm Date: Wed, 11 Jan 2023 20:51:07 -0600 Subject: Updated to account for selenium's by_tag deprectaion --- comedyGenerator | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/comedyGenerator b/comedyGenerator index 0a80a22..ac5b3da 100755 --- a/comedyGenerator +++ b/comedyGenerator @@ -27,7 +27,7 @@ parser.add_argument('--debug', ) parser.add_argument('-js','-JS',"--Javascript",'--javascript', - default=False, + default=True, action='store_true', dest='usingJavascript', help='Enables the user of a webdriver to scrape funnies' @@ -67,6 +67,7 @@ if not args.usingJavascript: urllib.request.urlretrieve(video['data-src'], '/home/' + os.environ['USER'] + '/Videos/unsorted/' + name) elif args.usingJavascript: from selenium import webdriver + from selenium.webdriver.common.by import By print("using JS mode...") try: @@ -136,12 +137,17 @@ elif args.usingJavascript: driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") isTimesScrolled = isTimesScrolled + 1 time.sleep(3) - videos = driver.find_elements_by_tag_name("video") + if args.debug: + print("Need to scroll " + str(oughtTimeScrolled-isTimesScrolled) + " more times...") + videos = driver.find_elements(By.TAG_NAME,"video") + if args.debug: + print("Original Videos List: ") + print(videos) if args.amount > 0: videos = videos[:args.amount] if args.debug: print("Videos list truncated! Its now: " + str(len(videos)) + " units long") - for video in videos: + for video in videos: URL = video.get_attribute("data-src") if args.debug: print("URL read as: " + URL) -- cgit v1.2.3