前言
為了看美劇《天蠍》,在電影天堂找到了,於是就想下載下來好好欣賞。
廢話不說了,直接上代碼。
代碼
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、喚起迅雷並賦值
運行后直接啟動了迅雷,我用的是迅雷極速版
注意:在進行下載之前需先啟動迅雷