| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 | 
							- """
 
- https://www.cyberforum.ru/python-graphics/thread2712141.html
 
- """
 
- import os
 
- from difflib import SequenceMatcher
 
- from tqdm import tqdm
 
- import datetime
 
- import requests
 
- # ссылка для проверки
 
- url = "http://213.155.192.79:3001/ypv/up/raw/master/%d0%a3%d1%87%d0%b5%d0%b1%d0%bd%d0%b0%d1%8f%20%d0%bf%d1%80%d0%b0%d0%ba%d1%82%d0%b8%d0%ba%d0%b0%2046%20%d0%b3%d1%80.%201%20%d1%81%d0%b5%d0%bc.%20-%202/%d0%92%d0%be%d0%bf%d1%80%d0%be%d1%81%d1%8b/%d0%a1%d0%ba%d0%b2%d0%be%d1%80%d1%86%d0%be%d0%b2%d0%b0%20%d0%94%d0%b8%d0%b0%d0%bd%d0%b03/%d0%92%d0%be%d0%bf%d1%80%d0%be%d1%81%2016.md"
 
- # директория файла
 
- BASE_DIR = os.path.abspath(os.path.dirname(__file__))
 
- print()
 
- response = requests.get(url)
 
- post_html = response.text
 
- files_paths = []
 
- dirs = os.listdir(BASE_DIR)
 
- for dir in dirs:
 
-     dir_path = os.path.join(BASE_DIR, dir)
 
-     if os.path.isdir(dir_path) and (dir != "__pycache__"):
 
-         files = os.listdir(dir_path)
 
-         for file in files:
 
-             file_path = os.path.join(BASE_DIR, dir, file)
 
-             filename, fileext = os.path.splitext(file)
 
-             if os.path.isfile(file_path) and (fileext=='.md'):
 
-                 files_paths.append(file_path)
 
- out_str = ""
 
- max_ratio = 0
 
- max_ratio_file = ""
 
- for file_1 in tqdm(files_paths):
 
-     small_filename_1 = str(file_1).replace(BASE_DIR, "").strip("\\")
 
-     try:
 
-         with open(file_1, encoding="utf-8") as f_1:
 
-             str1 = f_1.read()
 
-     except:
 
-         with open(file_1, encoding="cp1251") as f_1:
 
-             str1 = f_1.read()
 
-             f_1.close()
 
-         with open(file_1, 'w', encoding="utf-8") as f_1:
 
-             f_1.write(str1)
 
-             f_1.close()
 
-                     
 
-     ratio = int(SequenceMatcher(None, str1.lower(), post_html.lower()).ratio() * 100)
 
-     if (ratio > 70):
 
-         out_str += f"{small_filename_1}\n"
 
-         out_str += f"ratio = {ratio}\n"
 
-     if (ratio > max_ratio):
 
-         max_ratio = ratio
 
-         max_ratio_file = small_filename_1
 
- print(out_str)
 
- print()
 
- print(f"max ratio: {max_ratio}%")
 
- print(f"max ratio file: {max_ratio_file}")
 
- print("success")
 
 
  |