哔哩哔哩自动播放视频
# datetime:2020/10/7 16:33
# bilibili
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
#打开浏览器,实例化对象
driver=webdriver.Chrome()
shuru=driver.get('https://www.bilibili.com/')
driver.maximize_window()
#('window.scrollBy(左右距离,上下距离'),'')
shuru=driver.find_element_by_class_name('nav-search-keyword')
shuru.send_keys('恐怖')
shuru.send_keys(Keys.ENTER)
#窗口切换
#首先要获取 窗口对象
handles=driver.window_handles
driver.switch_to.window(handles[-1])
driver.find_element_by_css_selector('div.lazy-img').click()
#窗口切换
#首先要获取 窗口对象
handles=driver.window_handles
driver.switch_to.window(handles[-1])
driver.find_element_by_css_selector('div.bilibili-player-video-wrap').click()
#播放60秒
time.sleep(60)