Forums

ProxyError(Tunnel connection failed: 403 Forbidden)

I try to connect to 'https://core.telegram.org' (not in https://www.pythonanywhere.com/whitelist/ ) and get 'OSError: Tunnel connection failed: 403 Forbidden'.

After I try to connect to 'https://api.telegram.org' (in whitelist), but there is the same error.

What am I doing wrong?

python3 --version Python 3.7.0

import requests as req
a = req.get('https://api.telegram.org')

That sounds strange -- accessing api.telegram.org should work fine. I ran the code you posted above in a free account, and it looks like it worked to me:

Python 3.7.0 (default, Aug 22 2018, 20:50:05) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests as req
>>> a = req.get('https://api.telegram.org')
>>> a.status_code
200
>>> a.content
b'<!DOCTYPE html>\n<html>\n  <head>\n    <meta charset="utf-8">\n    <title>Bots: An introduction for developers</title>\n    <meta name="
viewport" content="width=device-width, initial-scale=1.0">\n    <meta property="description" content="Bots are third-party applications th
...

What happens when you run it?

It is very strange, but this code ('https://api.telegram.org') is working right now. Wow :)

Okay, could you tell me please, how I can get request to site not in whitelist? Because there is 403 error.

Send us a link to the API documentation and we'll consider it for inclusion in the whitelist.

What will I do if the site has no public API (for example, Tencent QQ or other)?

if they dont have an API, we will not allow free users to access the site. You may upgrade if you want to access it.