From 8a01f52c69cf8ec78f89d12de672cede2f0f5385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=B2=D0=B3=D0=B5=D0=BD=D0=B8=D0=B9=20=28=D0=A5?= =?UTF-8?q?=D1=80=D0=B0=D0=BC=D1=8B=D1=87=D0=AA=29=20=D0=A5=D1=80=D0=B0?= =?UTF-8?q?=D0=BC=D0=BE=D0=B2?= Date: Mon, 18 Aug 2025 12:41:41 +0300 Subject: [PATCH] =?UTF-8?q?-=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8?= =?UTF-8?q?=20=D1=81=20=D0=BB=D0=B8=D1=88=D0=BD=D0=B5=D0=B9=20=D1=81=D0=BA?= =?UTF-8?q?=D0=BE=D0=B1=D0=BA=D0=BE=D0=B9=20=D0=B2=20vk-=D1=84=D1=83=D0=BD?= =?UTF-8?q?=D0=BA=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content_processor.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/content_processor.py b/content_processor.py index 09f781c..38f2e6e 100644 --- a/content_processor.py +++ b/content_processor.py @@ -131,10 +131,16 @@ class ContentProcessor: def extract_links(self, text): self.logger.debug("Извлекаем ссылки из текста") - url_pattern = re.compile(r'https?://\S+') + # Улучшенное регулярное выражение, исключающее конечные знаки препинания + url_pattern = re.compile(r'https?://[^\s\)\]\}\>,;]+') links = url_pattern.findall(text) - self.logger.debug(f"Найденные ссылки: {links}") - return links + # Дополнительная очистка: убираем точки и запятые в конце + cleaned_links = [] + for link in links: + link = link.rstrip('.,!?') + cleaned_links.append(link) + self.logger.debug(f"Найденные ссылки: {cleaned_links}") + return cleaned_links def format_for_vk(self, content): """Форматирование контента для VK"""