Python批量下载电视剧电影--自己动手丰衣足食

前言

为了看美剧《天蝎》,在电影天堂找到了,于是就想下载下来好好欣赏。

废话不说了,直接上代码。

代码

 1 import requests,re,os,time
 2 url = "http://www.dygod.net/html/tv/oumeitv/109673.html"
 3 s = requests.get(url)
 4 # print(s.encoding) #打印下汉字的编码类型
 5 res = re.findall('href="(.*?)">ftp',s.text)
 6 for resi in res:
 7     #汉字转换成utf-8编码
 8     # print(i.encode("iso-8859-1").decode('gbk').encode('utf8').decode('utf8'))
 9     a=resi.encode("iso-8859-1").decode('gbk').encode('utf8').decode('utf8')
10     print(a) #打印一下看下效果
11     os.chdir("D:\Program Files (x86)\Thunder Network\Thunder\Program\")
12     os.system("Thunder.exe -StartType:DesktopIcon "%s"" % a)
13     time.sleep(1)

运行代码后效果图:

代码的运行思路:

1、获取网页的源文件

2、找到源文件中的下载链接

3、唤起迅雷并赋值

运行后直接启动了迅雷,我用的是迅雷极速版

注意:在进行下载之前需先启动迅雷

原文地址:https://www.cnblogs.com/hanxiaobei/p/7775342.html