Skip to content

Instantly share code, notes, and snippets.

@zhombie
zhombie / http-client.py
Created February 3, 2024 09:25
HTTP client
import aiohttp
import asyncio
import logging
import traceback
import uuid
from chardet import detect
from typing import Any, Optional, Tuple
logger = logging.getLogger(__name__)
@zhombie
zhombie / telethon-channel_info.py
Created March 9, 2020 12:32
Fetch full info from channel username
access_hash = await db.fetchval(
'''
SELECT extra ->> 'access_hash'
FROM scanning.accounts
WHERE channel = $1
''',
'tg'
)
tg = TelegramStreaming(
@zhombie
zhombie / example
Last active February 28, 2020 13:54
Telethon python library: Mini-script for obtaining web_preview text
def collect_article(self, blocks) -> str:
article = []
for block in blocks:
text = self.obtain_text(block)
if text:
article.append(text)
return '\n'.join(article)