parent
e9b8330573
commit
4a47fa1088
@ -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)
|
Loading…
Reference in new issue