保存芈月传的迅雷链接,保存芈迅雷链接,import urlli


import urllibimport reimport osimport syslst="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),urldef 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()

评论关闭