import datetime
import random
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from lxml import etree
# @Time : 2022/9/9 20:16
# @Author : 熊xiaohui
# @Software: PyCharm
clp=[]#储放地址
v=0
#自动 获取到哔哩哔哩里的 NBA形象大使蔡徐坤 第36页数据
for i in range(1,35):
if i==1:
c="https://search.bilibili.com/all?vt=13751909&keyword=%E8%94%A1%E5%BE%90%E5%9D%A4&from_source=webtop_search&spm_id_from=333.1007&search_source=5"
else:
v += 30
c='https://search.bilibili.com/all?vt=13751909&keyword=%E8%94%A1%E5%BE%90%E5%9D%A4&from_source=webtop_search&spm_id_from=333.1007&search_source=5&page='+str(i)+'&o='+str(v)
clp.append(c)
sertd=Service("\自动\chromedriver.exe")
#获取Service对象 对象:sertd
asd=webdriver.Chrome(service=sertd)
for mk in clp:
asd.get(mk)
asd.refresh()#刷新
dfg1=random.randint(6,10)
time.sleep(dfg1)
html=etree.HTML(asd.page_source)
name=html.xpath('//*[@class="bili-video-card__info--right"]/a/h3/@title')#名字
shul=html.xpath('//*[@class="bili-video-card__mask"]/div/div/span[1]/span/text()')#点赞数量
pijian=html.xpath('//*[@class="bili-video-card__mask"]/div/div/span[2]/span/text()')#
# for i in zip(name,shul,pijian):
# print(i)
for i1 in zip(name,shul,pijian):
print(i1)