1. 程式人生 > >用python下載美劇《天蠍》

用python下載美劇《天蠍》

小強測試品牌 測試幫日記 python 接口自動化測試

本文是小強全棧測試開發班學員投稿,比心!

前言


為了看美劇《天蠍》,終於在電影天堂網站找到了,嘎嘎,於是就想下載下來好好欣賞。

代碼


import requests,re,os,time

#電影的URL地址

url = "http://www.dygod.net/html/tv/oumeitv/109673.html"

s = requests.get(url)

# print(s.encoding) #打印下漢字的編碼類型

res = re.findall('href="(.*?)">ftp',s.text)

for resi in res:

#漢字轉換成utf-8編碼

# print(i.encode("iso-8859-1").decode('gbk').encode('utf8').decode('utf8'))

a=resi.encode("iso-8859-1").decode('gbk').encode('utf8').decode('utf8')

print(a) #打印一下看下效果

os.chdir("D:\Program Files (x86)\Thunder Network\Thunder\Program\")

os.system("Thunder.exe -StartType:DesktopIcon "%s"" % a)

time.sleep(1)

運行代碼後效果圖:

技術分享圖片

我用的是迅雷極速版,安裝在D盤。

註意:在進行下載之前需先啟動迅雷


用python下載美劇《天蠍》