from lxml import etree
import time
import requests
import pandas as pd
import random
headers = {
"user-agent":
"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1",
"Referer": "https://www.bilibili.com/",
}
url = 'https://www.bilibili.com/v/popular/rank/all'
res = requests.get(url = url,headers = headers)
text = res.text
html = etree.HTML(text)
li_list = html.xpath('//div[@class = "rank-list-wrap"]/ul[@class = "rank-list"]/li[@class = "rank-item"]')
for li in li_list:
up_name = li.xpath('div[@class = "content"]/div[@class = "info"]/div[@class = "detail"]/a/span/text()')[0]
up_id = li.xpath('div[@class = "content"]/div[@class = "info"]/div[@class = "detail"]/a/@href')[0].replace('//space.bilibili.com/','')
【Python】B站热门榜单热门视频UP主信息
最新推荐文章于 2024-05-04 12:51:05 发布