保存芈月传的迅雷链接

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

import urllib
import re
import os
import sys
lst="myz.lst"
bak_lst=lst+".bak"
urls=[]
def check():
    if os.path.exists(lst):
        with open(lst,'r') as f:
            cnt=f.read()
            if cnt:
                urls=cnt.split("\n")
                with open(bak_lst,'w') as ff:
                    ff.write(cnt)

    rlt=urllib.urlopen("http://www.xlpu.cc/html/42829.html?encode=1").read()
    al=re.findall(r'href="(thun.*?)"',rlt,re.S)
    rlt=set(al)-set(urls)
    if not rlt:
        print "No Change"
    else:
        with open(lst,'w') as f:
            f.write("\n".join(rlt))
            len_urls=len(rlt)
            print "%d movies add"%len_urls
            for ix,url in enumerate(rlt):
                print "[%d/%d]"%(ix+1,len_urls),url
def reset():
    if os.path.exists(bak_lst):
        os.remove(lst)
        os.rename(bak_lst,lst)
if __name__=="__main__":
    if "--reset" in sys.argv:
        reset()
    else:
        check()