After the page is saved, the JS file will be named. Download, HTML references will also have, very ugly, solution: Replace the string with Python
ImportOsImportRe"" Replace all documents in the current directory with "" "defChange_str (path): Str_pattern= r "\. Download"Str_new= r ""Path_list=Os.listdir (PATH) for file inchPath_list:abs_path=Os.path.join (Path,file)ifOs.path.isfile (Abs_path):ifRe.search (' (\.html) | (\.txt) ',file):Print(Abs_path) with Open(Abs_path,' R ', encoding="Utf-8") asF:str_all=F.read () with Open(Abs_path,' W ', encoding="Utf-8") asF:f.write (Re.sub (Str_pattern, Str_new, Str_all))# Modify File name if ". Download" inchAbs_path:new_name=Re.sub ("\. Download",'', Abs_path) Os.rename (Abs_path, new_name)Else: Change_str (Abs_path) change_str (Os.path.abspath ('.'))
Python replaces all text strings in the specified directory