获取电影最新下载列表,获取电影最新下载,# coding=gbk
文章由Byrx.net分享于2019-03-23 09:03:01
获取电影最新下载列表,获取电影最新下载,# coding=gbk
# coding=gbkimport requestsimport re#print requests.__doc__import sysimport codecs,urllib,urllib2import smtplibimport email.mime.textimport sqlite3import shelvef = open('text.txt','wb')def Mail(username,password,mail_from,mail_to,subject,content): HOST = 'smtp.gmail.com' PORT = 25 smtp = smtplib.SMTP() smtp.set_debuglevel(1) try: print smtp.connect(HOST,PORT) smtp.starttls() smtp.login(username,password) msg = email.mime.text.MIMEText(content, 'html', 'gbk') msg['From'] = mail_from msg['To'] = ';'.join(mail_to) msg['Subject']= subject smtp.sendmail(mail_from,mail_to,msg.as_string()) smtp.quit() except Exception,e: print e return -1g_html_head="""<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><meta http-equiv="X-UA-Compatible" content="IE=8" /><meta content="FFDY" name="keywords" /><title>放放电影 最新电影 在线观看</title><link href="css.css" rel="stylesheet" type="text/css" /><script type="text/javascript" src="function-1.0.1.js"></script></head><body><div class="container"> <div class="col1"> <h2>最新电影下载:</h2> <div class="content"> <ul>"""g_html_tail=""" </ul> </div> </div></div></body></html>"""g_html_content = """<li><a href="%s" target="_blank">%s</a>"""def main(): global g_html_content global g_html_tail global g_html_head g_count = 0 save = shelve.open('urls.dat') fout = open('test.html','wb') while g_count<5: g_count+=1 try: url = 'http://www.ffdy.cc/' #opener = urllib2.urlopen(url) #urllib2.install_opener(opener) print 'start open : %s' % url req = urllib2.Request(url) print 'reading ...' c = urllib2.urlopen(req).read() print c new_list = re.findall('\\<a href\\="(movie.*?)" target\\=\\"_blank\\"\\>([^\\<].*?)\\</a\\>',c) content = g_html_head new_count = 0 for item in new_list: url = 'http://www.ffdy.cc/'+item[0] if save.has_key(url): print 'Repeat : %s' % save[url] continue save[url]=item[1] content+= g_html_content % (url,item[1]) print item[0],item[1] new_count+=1 content+= g_html_tail fout.write(content) #print ';'.join(['[email protected]']) if new_count>0: print 'New : %d' % new_count Mail('[email protected]','harktest','[email protected]',['[email protected]'],'FFDY.cc',content) else: print 'There is No New Vedio' except Exception,e: print 'FAIL :',e print 'TRY Again' else: print 'Fetch OK' breakif __name__ == '__main__': main()#该片段来自于http://byrx.net
相关内容
- 打开文件对话框,,from tkinter
- Session for Tornado(Redis),tornadoredis,session id的生
- 使用python登录人人网并发表状态,python登录人人发表
- 使用Python解决FizzBuzz问题,python解决fizzbuzz,FizzBuzz问题描
- 文件夹对比,,买了个移动硬盘备份 但是
- 简单模拟编译前端过程,简单模拟编译过程,学了几天
- 文本文件常用工具,,common_lib/u
- 模拟登录人人网,模拟登录人人,from seleniu
- UPS电源下,自动关机,UPS电源,自动关机,停电后,在U
- 获取页面url,页面url,import reimp
评论关闭