Forums

can not connect to a site via Request module

I have made and script and i need to check content of a site (ghasedak24.com) but pythonanywhere refuse to connect to that site

LINK = "https://ghasedak24.com/search/flight/BND-THR/1397-08-15/1-0-0"
origin=BND&destination=THR,IKA&departureDate=1397-08-15"

def spooky(LINK):

    r = requests.get(LINK)# proxies=proxyDict
    c = r.content

and it cause this error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
    self._prepare_proxy(conn)
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 810, in _prepare_proxy
    conn.connect()
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connection.py", line 294, in connect
    self._tunnel()
  File "/usr/lib/python3.6/http/client.py", line 919, in _tunnel
    message.strip()))
OSError: Tunnel connection failed: 403 Forbidden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/util/retry.py", line 376, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='ghasedak24.com', port=443): Max retries exceeded with url: /search/flight/BND-THR/1397-08-15/1-0-0 (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden',)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sinamim/app_for_moj.py", line 34, in <module>
    print(spooky(LINK))
  File "/home/sinamim/app_for_moj.py", line 14, in spooky
    r = requests.get(LINK)# proxies=proxyDict
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
    self._prepare_proxy(conn)
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 810, in _prepare_proxy
    conn.connect()
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connection.py", line 294, in connect
    self._tunnel()
  File "/usr/lib/python3.6/http/client.py", line 919, in _tunnel
    message.strip()))
OSError: Tunnel connection failed: 403 Forbidden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/util/retry.py", line 376, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='ghasedak24.com', port=443): Max retries exceeded with url: /search/flight/BND-THR/1397-08-15/1-0-0 (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden',)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sinamim/app_for_moj.py", line 34, in <module>
    print(spooky(LINK))
  File "/home/sinamim/app_for_moj.py", line 14, in spooky
    r = requests.get(LINK)# proxies=proxyDict
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
    self._prepare_proxy(conn)
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 810, in _prepare_proxy
    conn.connect()
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connection.py", line 294, in connect
    self._tunnel()
  File "/usr/lib/python3.6/http/client.py", line 919, in _tunnel
    message.strip()))
OSError: Tunnel connection failed: 403 Forbidden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/util/retry.py", line 376, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='ghasedak24.com', port=443): Max retries exceeded with url: /search/flight/BND-THR/1397-08-15/1-0-0 (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden',)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sinamim/app_for_moj.py", line 34, in <module>
    print(spooky(LINK))
  File "/home/sinamim/app_for_moj.py", line 14, in spooky
    r = requests.get(LINK)# proxies=proxyDict
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
    self._prepare_proxy(conn)
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 810, in _prepare_proxy
    conn.connect()
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connection.py", line 294, in connect
    self._tunnel()
  File "/usr/lib/python3.6/http/client.py", line 919, in _tunnel
    message.strip()))
OSError: Tunnel connection failed: 403 Forbidden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/util/retry.py", line 376, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='ghasedak24.com', port=443): Max retries exceeded with url: /search/flight/BND-THR/1397-08-15/1-0-0 (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden',)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sinamim/app_for_moj.py", line 34, in <module>
    print(spooky(LINK))
  File "/home/sinamim/app_for_moj.py", line 14, in spooky
    r = requests.get(LINK)# proxies=proxyDict
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
    self._prepare_proxy(conn)
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 810, in _prepare_proxy
    conn.connect()
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connection.py", line 294, in connect
    self._tunnel()
  File "/usr/lib/python3.6/http/client.py", line 919, in _tunnel
    message.strip()))
OSError: Tunnel connection failed: 403 Forbidden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/util/retry.py", line 376, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='ghasedak24.com', port=443): Max retries exceeded with url: /search/flight/BND-THR/1397-08-15/1-0-0 (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden',)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sinamim/app_for_moj.py", line 34, in <module>
    print(spooky(LINK))
  File "/home/sinamim/app_for_moj.py", line 14, in spooky
    r = requests.get(LINK)# proxies=proxyDict
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
    self._prepare_proxy(conn)
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 810, in _prepare_proxy
    conn.connect()
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connection.py", line 294, in connect
    self._tunnel()
  File "/usr/lib/python3.6/http/client.py", line 919, in _tunnel
    message.strip()))
OSError: Tunnel connection failed: 403 Forbidden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/util/retry.py", line 376, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='ghasedak24.com', port=443): Max retries exceeded with url: /search/flight/BND-THR/1397-08-15/1-0-0 (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden',)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sinamim/app_for_moj.py", line 34, in <module>
    print(spooky(LINK))
  File "/home/sinamim/app_for_moj.py", line 14, in spooky
    r = requests.get(LINK)# proxies=proxyDict
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
    self._prepare_proxy(conn)
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 810, in _prepare_proxy
    conn.connect()
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connection.py", line 294, in connect
    self._tunnel()
  File "/usr/lib/python3.6/http/client.py", line 919, in _tunnel
    message.strip()))
OSError: Tunnel connection failed: 403 Forbidden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/util/retry.py", line 376, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='ghasedak24.com', port=443): Max retries exceeded with url: /search/flight/BND-THR/1397-08-15/1-0-0 (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden',)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sinamim/app_for_moj.py", line 34, in <module>
    print(spooky(LINK))
  File "/home/sinamim/app_for_moj.py", line 14, in spooky
    r = requests.get(LINK)# proxies=proxyDict
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
    self._prepare_proxy(conn)
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 810, in _prepare_proxy
    conn.connect()
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connection.py", line 294, in connect
    self._tunnel()
  File "/usr/lib/python3.6/http/client.py", line 919, in _tunnel
    message.strip()))
OSError: Tunnel connection failed: 403 Forbidden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/util/retry.py", line 376, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='ghasedak24.com', port=443): Max retries exceeded with url: /search/flight/BND-THR/1397-08-15/1-0-0 (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden',)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sinamim/app_for_moj.py", line 34, in <module>
    print(spooky(LINK))
  File "/home/sinamim/app_for_moj.py", line 14, in spooky
    r = requests.get(LINK)# proxies=proxyDict
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
    self._prepare_proxy(conn)
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 810, in _prepare_proxy
    conn.connect()
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connection.py", line 294, in connect
    self._tunnel()
  File "/usr/lib/python3.6/http/client.py", line 919, in _tunnel
    message.strip()))
OSError: Tunnel connection failed: 403 Forbidden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/util/retry.py", line 376, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='ghasedak24.com', port=443): Max retries exceeded with url: /search/flight/BND-THR/1397-08-15/1-0-0 (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden',)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sinamim/app_for_moj.py", line 34, in <module>
    print(spooky(LINK))
  File "/home/sinamim/app_for_moj.py", line 14, in spooky
    r = requests.get(LINK)# proxies=proxyDict
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
    self._prepare_proxy(conn)
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 810, in _prepare_proxy
    conn.connect()
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connection.py", line 294, in connect
    self._tunnel()
  File "/usr/lib/python3.6/http/client.py", line 919, in _tunnel
    message.strip()))
OSError: Tunnel connection failed: 403 Forbidden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/dist-packages/requests/packages/urllib3/util/retry.py", line 376, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='ghasedak24.com', port=443): Max retries exceeded with url: /search/flight/BND-THR/1397-08-15/1-0-0 (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden',)))

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/sinamim/app_for_moj.py", line 34, in <module>
    print(spooky(LINK))
  File "/home/sinamim/app_for_moj.py", line 14, in spooky
    r = requests.get(LINK)# proxies=proxyDict
  File "/usr/local/lib/python3.6/dist-packages/requests/api.py", line 70, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 485, in send
    raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='ghasedak24.com', port=443): Max retries exceeded with url: /search/flight/BND-THR/1397-08-15/1-0-0 (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden',)))
>>>

how can i fix it?

See http://help.pythonanywhere.com/pages/403ForbiddenError/