获取哔哩哔哩热点前十与其热度数据
import requests
import re
import os
import pandas as pd
url = 'https://tophub.today/n/74KvxwokxM'
headers = {'user-Agent':'5787665'}
response = requests.get(url,headers = headers)
html = response.text
#print(html)
urls = re.findall('<a href=".*?">.*?(.*?)</a>',html)[4:14]
rd = re.findall('<td>(.*?)</td>',html)[0:10]
#print(urls,rd)
a = {'标题':urls,'热度':rd}
newfile = pd.DataFrame(a)
os.chdir(r'E:\文件')
newfile.to_csv('file.csv')
print(newfile)

浙公网安备 33010602011771号