简易的爬虫
话不多说直接上代码
import requests
from bs4 import BeautifulSoup
m = requests.get('https://www.bilibili.com/v/popular/rank/movie')
t = requests.get('https://www.bilibili.com/v/popular/rank/tv')
html1 = m.content
html2 = t.content
movie = BeautifulSoup(html1, 'html.parser')
tv = BeautifulSoup(html2, 'html.parser')
div_list1 = movie.find('ul', attrs={'class': 'rank-list'})
div_list2 = tv.find('ul', attrs={'class': 'rank-list'})
arf1 = div_list1.find_all('a', attrs={'class': 'title'})
arf2 = div_list2.find_all('a', attrs={'class': 'title'})
for x1 in arf1:
url1 = x1['href']
name = x1.get_text()
print(name+'\t点击观看链接:'+f'http:{url1}')
for x2 in arf2:
url2 = x2['href']
name2 = x2.get_text()
print(name2+'\t点击观看链接:'+f'http:{url2}')
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)