变更
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import self as self
|
||||
from selenium.webdriver import Chrome, Keys # 键盘操作
|
||||
import time
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
from selenium.webdriver.common.by import By
|
||||
|
||||
web = Chrome()
|
||||
|
||||
option = Options()
|
||||
option.add_argument('--disable_blink_features=AutomationControlled')
|
||||
|
||||
web.get('https://t.bilibili.com/19929202306164175')
|
||||
|
||||
# 点击转发
|
||||
test_poet1 = web.find_element(By.XPATH, r'//*[@id="app"]/div[2]/div/div/div[1]/div[4]/div[1]/div')
|
||||
test_poet1.click()
|
||||
# 防止不能加载不出来
|
||||
time.sleep(2)
|
||||
|
||||
number = 0
|
||||
al_list = web.find_elements(By.CLASS_NAME, 'bili-dyn-forward__item')
|
||||
|
||||
for al in al_list:
|
||||
name = al.find_element(By.CLASS_NAME, 'default').text
|
||||
content = al.find_element(By.CLASS_NAME, 'bili-rich-text__content').text
|
||||
print(name, content)
|
||||
number += 1
|
||||
if number % 7 == 0:
|
||||
web.execute_script('window.scrollTo(0,document.body.scrollHeight)')
|
||||
# time.sleep(50000)
|
||||
try:
|
||||
web.find_element(By.XPATH,"/html/body").send_keys(Keys.UP)
|
||||
|
||||
time.sleep(50000)
|
||||
except:
|
||||
pass
|
||||
web.execute_script('window.scrollTo(0,document.body.scrollHeight)')
|
||||
time.sleep(5)
|
||||
|
||||
time.sleep(10000)
|
||||
Reference in New Issue
Block a user