From 4a47fa10883d6c90354a6adff3d1636cd196c09f Mon Sep 17 00:00:00 2001 From: posql3f6g <2974352416@qq.com> Date: Mon, 10 Apr 2023 20:10:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=BE=97=E5=8D=9A=E4=B8=BB=E4=B8=BB?= =?UTF-8?q?=E9=A1=B5=E8=A7=86=E9=A2=91=E9=93=BE=E6=8E=A5=E5=92=8C=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E6=80=BB=E9=A1=B5=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 搜索博主.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 搜索博主.py diff --git a/搜索博主.py b/搜索博主.py new file mode 100644 index 0000000..49197ed --- /dev/null +++ b/搜索博主.py @@ -0,0 +1,39 @@ +import requests +from lxml import etree +from selenium import webdriver +import time +from bs4 import BeautifulSoup +import re +# 480959917 +# 1856528671 +# https://space.bilibili.com/480959917/video +# https://space.bilibili.com/480959917/video?tid=0&page=2&keyword=&order=pubdate +uid=input('请输入你想要看的博主的uid:') +base_url='https://space.bilibili.com' +url=base_url+'/'+uid+'/video' +path='chromedriver.exe' +browser=webdriver.Chrome(path) +browser.get(url) +time.sleep(2) +detial_url_list = [] +html = BeautifulSoup(browser.page_source) +last_page=html.find('div',id='submit-video-list').find('ul',class_='be-pager').find_all('li')[-2].find('a').text +# [-2].find('a').text +print(last_page) + +for a_label in html.find('div', id='submit-video-list').find_all('a',attrs={'target': '_blank', 'class': 'title'}): + if (a_label['href'] != None): + detial_url_list.append('https:' + a_label['href']) + +print(detial_url_list) +# print(url) +# headers={ +# 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36', +# } +# +# response=requests.get(url=url,headers=headers) +# response.encoding='UTF-8' +# print(response.text) +# tree = etree.HTML(response.text) +# vedio_url_list=tree.xpath('//div[@class="s-space"]//div[@id="video-list-style"]//ul[@class="clearfix cube-list"]/li/a/@href') +# print(vedio_url_list) \ No newline at end of file