How to use proxy in telethon?

See original GitHub issue
import sys
import socks

from telethon import TelegramClient
from telethon.tl.types import InputPhoneContact
from telethon.tl.functions.contacts import ImportContactsRequest
from telethon.errors import FloodWaitError, RPCError

api_id = 0  # a valid api_id
api_hash = ''  # a valid api_hash

w = input('Which: ')

host = 8.8.8.8  # a valid host
port = 80  # a valid port
proxy = (socks.SOCKS5, host, port)

client = TelegramClient('N{}'.format(w), api_id, api_hash, proxy)
client.connect()

Above code doesn’t work. what is the problem???

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

8reactions
hameda169commented, Sep 5, 2017

with another proxy:))

3reactions
Lonamicommented, Sep 5, 2017

What worked?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hiding behind proxy using Telethon/Socks5 - Stack Overflow
You should use a different syntax for the proxy: from telethon.sync import TelegramClient, events import socks api_id = '' api_hash ...
Read more >
Signing In — Telethon 1.26.0 documentation
If you need to use a proxy to access Telegram, you will need to either: ... (of course, replacing the protocol, IP and...
Read more >
Telethon - PyPI
If you want to use Telethon via proxy, you have to install PySocks (via pip or manual). Once this is done, pass the...
Read more >
how to use mtproto proxy for telethon - Code Grepper
from telethon import TelegramClient, connection # we need to change the connection ^^^^^^^^^^ client = TelegramClient( 'anon', api_id, api_hash, # Use one ...
Read more >
Python Tutorial: Scraping Telegram with Datacenter Proxies
... using Python and Datacenter proxies to scrape messages, group members and more. You'll also need Telegram credentials and Telethon ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found