requests
:
import requests
proxies = {
'http': 'socks5h://user:pass@host:port',
'https': 'socks5h://user:pass@host:port'
}
requests.post(url, proxies=proxies)
python-telegram-bot
:
import telegram
from telegram.utils.request import Request
from telegram.ext import Updater
# bot 发消息的脚本
bot = telegram.Bot(token='token', request=Request(proxy_url='socks5h://user:pass@host:port'))
bot.send_message(chat_id='chat_id', text='hello')
# bot 服务
updater = Updater(token='token', request_kwargs={'proxy_url': 'socks5h://user:pass@host:port'})
See Also
- Python: Daily Tasks 中描述 socks5 代理的部分
- Python: URL Handling