from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from bs4 import BeautifulSoup
from moviepy.editor import *
from natsort import natsorted
import os
import time
import shutil
import codecs
import requests
def downloadvideo(videourl):
videourl = 'https://author.baidu.com/home/' + videourl
chrome_options = Options()
chrome_options.add_argument("--start-maximized")
browser =
webdriver.Chrome('C:/Users/Administrator/AppData/Local/Programs/Python/Python310/chrom
edriver.exe', chrome_options=chrome_options)
browser.get(videourl)
time.sleep(3)
js = "return action=document.body.scrollHeight"
height = browser.execute_script(js)
t1 = int(time.time())
browser.execute_script('window.scrollTo(0, document.body.scrollHeight)')
time.sleep(5)
status = True
num = 0
while status:
t2 = int(time.time())
if t2-t1 < 30:
new_height = browser.execute_script(js)
if new_height > height :
time.sleep(1)
browser.execute_script('window.scrollTo(0, document.body.scrollHeight)')
height = new_height
t1 = int(time.time())
elif num < 3:
time.sleep(3)
num = num + 1
else:
status = False
browser.execute_script('window.scrollTo(0, 0)')
break
html = browser.page_source