全集⽹影⽚下载#!/user/bin/python
#encoding=utf-8
#此程序只是模仿默认浏览器打开迅雷链接实现⾃动下载,电脑必须装有迅雷,下载路径为迅雷默认下载路径import requests
import re
import webbrowser
import Levenshtein      #相识度匹配模块,⽤于判断下载连续剧
import time
#输⼊电影名并⽣成data内容
def get_datas():
search_name = raw_input('please input the video name you wanted:')
data = {'wd':search_name}                #data由抓包软件HTTPAnalyzerFullV7获得
return search_name,data
##post⽅式获取⽹页内容
def get_response0(data,search_url):
response = requests.post(url=search_url,data=data).content
return response
##get⽅式获取页⾯内容
王宝强子女def get_response1(links_url):
response = (links_url).content
return response
##获取电影下载页⾯url
def get_downloadpage():
datas = get_datas()
search_name = datas[0]
data = datas[1]
response = get_response0(data,search_url)
downloadpage_url = re.findall('</a></div><a href="(.*?)"><h3>.*?%s.*?</h3>'%search_name,response) return downloadpage_url
##判断电影是否存在,若存在,下载电影
def download_movie(search_num,start_url):
马晓晴近况
try:
links_url = get_downloadpage()
links_url = start_url+links_url[0]
links_url = links_url.split('"><h3>')[0]
print'downloadpage_url:',links_url
response = get_response1(links_url)
##获取内容下载链接
links_list = re.findall('<li id="li\d+_.*?"><a href="(.*?)" title',response)
print'The num of links is %s'%len(links_list)            #记录可下载的链接数
崔雪梨
fail_time = 0                      #记录下载失败次数
download_num = 0                    #记录下载次数
link_standard = links_list[0]
for link in links_list:
#判断链接相似度(字符串长度⼀致),若存在,则继续;不存在则退出循环
try:
Levenshtein.hamming(link,link_standard)
time.sleep(3)                                    #打开链接的间断时间
except:
小康生活的标准是什么
break
#尝试下载
try:
webbrowser.open(link)
草坪标语download_num += 1
print'Download link:\n%s'%link
%s'%download_num
except:
fail_time += 1
pass
if fail_time != 0:
print'Have failed %s times!'%fail_time
if fail_time == len(links_list):
print'Download fail'
except:
if search_num < 2:
print"The movie name you had input is not foud or incomplete,please "
search_num += 1
download_movie(search_num,start_url)
else:
print'Beyond the input limit!'
if__name__ == '__main__':
start_url = 'www.quanji.la'#全集⽹⾸页
search_url = start_url + '/index.php?s=vod-search'#搜索页⾯
search_num = 0                                            #记录输⼊次数
印小天遭妻子骗婚
download_movie(search_num,start_url)
  程序可下电影也可下连续剧,最主要的前提是输⼊的“search_name”⼀定要对(我们⽚⼦的时候特别是外国⽚会有多个译名,输⼊的译名全集⽹得有)。
  python刚学习不久,程序的质量不咋地,欢迎各路好友多指点!