The first written reptiles, like men of God, and consequently do not say, on the code, there is something wrong correct me trouble
import re
import os
import time
def get_secend_url(url):#获取第一层的地址
r = requests.get(url)
data = r.text.encode("latin1").decode("UTF-8")
last_url = r'/shipin/(?<!\d)\d{5}(?!\d).html'
url_data = re.findall(last_url,data)
for i in range(len(url_data)):
print(domain_name+url_data[i])
get_end_url(domain_name+url_data[i])
def sleep(mytime):
time.sleep(mytime)
def get_end_url(url):#获取最终下载地址
r = requests.get(url)
data = r.text.encode("latin1").decode("UTF-8")
title_first = data.split('<title>')
title = title_first[1].split("</title>")
print(title[0])
last_url = '(https*(\S+).mp4)'
end_url = re.findall(last_url,data)
f = open('add.txt','a')#写入文本方便以后改名
f.write((title[0]+'++'+end_url[0][0])+',')
f.close()
sleep(10)#sleep 10s
print(end_url[0][0])
download(end_url[0][0])
#print(get_end_url(url))
def download(url): #调用迅雷下载文件,迅雷要设置自动下载
os.system(r'"C:\Program Files (x86)\Thunder Network\Thunder\Program\Thunder.exe" {url}'.format(url=url))
for i in range(1,99):
domain_name = '******'
url = domain_name+'/shipin/list-******81-'+str(i)+'.html'
print(url)
url_0 = get_secend_url(url)