Поиск по тегам

This commit is contained in:
2025-11-02 22:39:17 +03:00
parent 4046d3f8ea
commit d8047fdf21
8 changed files with 224 additions and 0 deletions

21
1.py Normal file
View File

@@ -0,0 +1,21 @@
from pymongo import MongoClient
def clean_tags_in_database():
client = MongoClient('mongodb://localhost:27017/')
db = client['Manga']
collection = db['Hentai_Manga']
for manga in collection.find():
if 'tags' in manga:
cleaned_tags = [tag.strip() for tag in manga['tags'] if tag.strip()]
if cleaned_tags != manga['tags']:
collection.update_one(
{'_id': manga['_id']},
{'$set': {'tags': cleaned_tags}}
)
print("Теги успешно очищены от пробелов")
# Вызовите эту функцию один раз
clean_tags_in_database()