@fight4f · Post #8035 · 24.02.2024 г., 22:00
特拉維夫,反內塔尼亞胡示威 (有人被捕) https://t.me/wc_israel/32900?single #zionists 訊息 : 在特拉維夫和以色列其他主要城市,經常發生反政府示威活動,要求與哈馬斯武裝分子達成協議以釋放人質。 此外,抗議者也呼籲以色列總理內塔尼亞胡下台,並主張提前選舉。 https://t.me/rybar/57544?single
Hashtags
TGINSIGHT SIMILAR POSTS
Изворен канал @pythonotes · Post #121 · 20 јул.
Регулярно требуется преобразовать какой-либо текст в максимально совместимый текст для URL, имени файла, имени объекта в каком-то софте и тд. Требования совместимости простые: в тексте должны быть только допустимые символы. Обычно это a-z, 0-9 и "_" или "-". То есть, только прописные буквы латинского алфавита и цифры (как пример). Допустим, нам нужно название статьи в блоге преобразовать в slug для добавления его в URL этой статьи. Как это лучше всего сделать? В Django по умолчанию есть готовая функция slugify для таких случаев. Но я её никогда не использую. Почему? Потому что её недостаточно! Приведём пример >>> from django.utils.text import slugify >>> slugify('This is a Title') 'this-is-a-title' Пока всё отлично >>> slugify('This is a "Title!"') 'this-is-a-title' Спец символы удалились, всё хорошо. >>> slugify('Это заголовок статьи') '' Вот и приехали 😢. Если текст не английский то буквы просто игнорируются. Можно это поправить >>> slugify('Это заголовок статьи', allow_unicode=True) 'это-заголовок-статьи' Но тогда мы не вписываемся в условие. У нас появилась кириллица в тексте. Так как я часто пишу сайты для русскоязычных пользователей эта проблема весьма актуальна. Я не использую стандартную функцию и всегда пишу свою. Оригинал я не беру в расчёт и пишу полностью свою функцию. И так, по порядку: 🔸1. Исходный текст: >>> text = 'Мой заголовок №10 😁!' Взял специально посложней со специальными символами. 🔸2. Транслит Необходимо сделать транслит всех символов в латиницу. Здесь очень выручает библиотека unidecode. Помимо простого транслита кириллицы в латиницу она умеет преобразовывать спец символы и иероглифы в текстовые аналоги. from unidecode import unidecode >>> unidecode("Ñ Σ ® µ ¶ ¼ 月 山") 'N S (r) u P 1/4 Yue Shan' Очень крутая библиотека, советую👍 В нашем случае получаем такое преобразование: >>> text = unidecode(text) >>> print(text) 'Moi zagolovok No. 10 !' Отличный транслит. Смайл просто удалился, хотя я ждал что-то вроде :). Ну и ладно, всë равно невалидные символы. А еще наш код уже поддерживает любой язык, будь то хинди или корейский. 🔸4. Фильтр символов Unidecode не занимается фильтрацией по недопустимым символам. Это мы делаем в следующем шаге через regex. Просто заменим все символы на "_" если они вне указанного диапазона. >>> text = re.sub(r'[^a-zA-Z0-9]+', '_', text) >>> print(text) 'Moi_zagolovok_No_10_' Символ "+" в паттерне выручает когда несколько недопустимых символов идут рядом. Все они заменяются на один символ "_". 🔸5. Slugify Осталось удалить лишние символы по краям и сделать нижний регистр >>> text = text.strip('_').lower() >>> print(text) 'moi_zagolovok_no_10' Получаем отличный slug! 😎 🌎 Полный код в виде функции. ______________ PS. Проверку что в строке остался хоть один допустимый символ я бы вынес в отдельную функцию. #libs#tricks#django
Пребарај: #zionists
@fight4f · Post #8035 · 24.02.2024 г., 22:00
特拉維夫,反內塔尼亞胡示威 (有人被捕) https://t.me/wc_israel/32900?single #zionists 訊息 : 在特拉維夫和以色列其他主要城市,經常發生反政府示威活動,要求與哈馬斯武裝分子達成協議以釋放人質。 此外,抗議者也呼籲以色列總理內塔尼亞胡下台,並主張提前選舉。 https://t.me/rybar/57544?single
Hashtags
@fight4f · Post #8011 · 17.02.2024 г., 22:19
Ukraine: the founder of the 'Nazi' 'Azov Battalion' is a Zionist) #zionists
Hashtags
@fight4f · Post #7961 · 08.02.2024 г., 08:33
今日新聞: 荷蘭以色列使館加強保安 1 以色列得罪人多 2 假裝受害者 #zionists
Hashtags
@fight4f · Post #7933 · 03.02.2024 г., 20:12
特拉維夫 今天以色列人質家屬和示威者封鎖了特拉維夫的一條街道,要求內塔尼亞胡政府辭職。 https://t.me/Intelsky/11450 #Zionists
Hashtags
@CulturalExile14 · Post #3514 · 10.03.2022 г., 18:11
The words of an insightful businessman or just the #Zionists' messenger boy? #Trump https://youtu.be/9PVFqpOHPBg
@fight4f · Post #8003 · 15.02.2024 г., 16:45
今晚幾個地區的人也去支援 Leiden 市火車站集會, 因為有打對台搞親以色列集會。 #zionists #Actie #actie #Gaza #sitins
@YediotNewsChat · Post #4975 · 22.12.2023 г., 07:32
In the Palestinian war with the Jewish terrorists, the people of the world changed their attitude. The people of the world used to receive news from official media and government-affiliated organizations. News agencies such as Associated Press, France Press, United Press, Reuters and many major news agencies in the world are in the hands of #Zionists. But in the Palestine war, the people of the world turned to individual media such as Telegram, Twitter and Tik Tok to discover the truth. The social networks that were built for the #Illuminati to dominate have become the nightmare of the #Freemasons. https://t.me/YediotNewsChat
Hashtags
@YediotNewsChat · Post #5127 · 30.12.2023 г., 15:02
Lebanon's Hezbollah proudly announces the names and pictures of its martyrs. Because martyrdom is the highest level that a Muslim can reach. But the #Zionists hide the names of their dead. Because the Jews fear death for their deeds. Of course, a large number of soldiers in the Israeli army are #Hindus. Israel uses #Zombies as shields. https://t.me/YediotNewsChat
@YediotNewsChat · Post #5098 · 29.12.2023 г., 12:52
Some news sources say that the price of internet has increased in some Muslim countries. Social networks and individual media have become an important tool to deal with the #Zionists. Because the state media is under the control of the #Jews. Official and government news agencies publish selected news in favor of the Zionists. But social networks publish real news. Individual media are putting pressure on Israel. They have increased the price of the Internet to reduce the activity of individual media. Every word and picture published against the Zionists will hit the body of #Illuminati and #Freemasonry like a bullet. https://t.me/YediotNewsChat
@YediotNewsChat · Post #4814 · 14.12.2023 г., 08:53
The name of this religious school is "Darul Uloom #Deoband". This huge place is located in India. #Zionists pump deviant Islamic thoughts day and night and produce thousands of terrorists. After graduation, they join terrorist groups like #Taliban, #Al-Qaeda, #ISIS. #Mufti, #Maulvi and #Mamusta are taught that if you kill 5 Muslims, you will go to heaven. What is the result of these schools? Have they been able to improve the critical situation of #Afghanistan and #Pakistan? Graduates of these schools spread war, poverty and ignorance among Muslims. Did #Hindus who worship cows and burn Muslims alive set up these schools for the growth of Islam? Did the Hindus unite with Islam or did they establish it to fight between Islamic groups? Why don't these groups (Deobandi, #Salafi, #Wahhabi) fight with USA and Israel? https://t.me/YediotNewsChat