Forums

Problem configuring proxy

Hello,

as a free account user, I'm trying to use pythonanywhere proxy to use cloudinary api.

I'm sorry but I am a total newbie with proxies things... (and I'm french so excuse me for my bad english)

I know there is an http server => proxy.server:3128.

Do I have to put this verbatim ? Or do I have to find values for "proxy" and "server" ?

Because this code in Pyhton doesn't work :

import requests

 proxies = {
       'http': 'proxy.server:3128',
       'https': 'proxy.server:3128',
 }

url='https://####:####@api.cloudinary.com/v1_1/###/resources/image"

resp = requests.get(url, proxies=proxies)

photos = resp.json()

Thank you in advance.

Bertz

Those are the correct proxy settings. In what way does it not work?

Hi, with this config :

proxies = { 'http': 'http://proxy.server:3128', 'https': 'http://proxy.server:3128', }

I got this message :

HTTPSConnectionPool(host='api.cloudinary.com', port=443): Max retries exceeded with url: /v1_1/###/resources/image (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000001BCBB2A1400>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')))

Try with proxies = {'http': 'proxy.server:3128', 'https': 'proxy.server:3128'} instead.

Same message :

HTTPSConnectionPool(host='api.cloudinary.com', port=443): Max retries exceeded with url: /v1_1/###/resources/image (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000001D90C20EBE0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')))

:(

Curiously, this code is ok when I run it in the pythonanywhere bash console. I get the error message only when I run it locally or at myaccount.pythonanywhere.com

Could you try the call without setting proxy? The requests library loads the proxy info from the environment. So the code would look like:

url='https://####:####@api.cloudinary.com/v1_1/###/resources/image"

resp = requests.get(url)

photos = resp.json()

Well, everything is ok now in local. But... it does not work on pythonanywhere.com.

The error message is :

'MaxRetryError' object has no attribute 'message'

Ok, so I've made a new simple site, and all seems to work. I think I have to look for a cleaner code. Thank you, I will make some tries and if I get other problems, I sure will come back. ;)

What is the full traceback?

It seems to be ok, there was a problem in my settings files. No problem for me now, thanks again !

Glad to hear that!

I was facing the same issue and it was resolved by writing this exact same code snippet.

import cloudinary
cloudinary.config(
  cloud_name = config('CLOUD_NAME'),
  api_key = config('CLOUD_API_KEY'),
  api_secret = config('CLOUD_API_SECRET'),
  api_proxy = "http://proxy.server:3128"
)
import cloudinary.uploader
import cloudinary.api

Thanks for letting us know!

Hey Bertz, no worries about your English, we're all here to help each other out!

.

import requests
from bs4 import BeautifulSoup
proxies = {
   'http': 'proxy.server:3128',
   'https': 'proxy.server:3128'
}
url="https://auth.geeksforgeeks.org/user/shaurydeepsaxena"
response = requests.get(url,proxies=proxies)
print(response)
soup = BeautifulSoup(response.text, 'html.parser')
elements = soup.find_all('span', {'class': 'score_card_value'})
print(elements)
text = elements[1].text.strip()
print(text)
# return text

What's the problem here even I am using proxy now? still showing this error:

requests.exceptions.ProxyError: HTTPSConnectionPool(host='auth.geeksforgeeks.org', port=443): Max retries exceeded with url: /user/shaurydeepsaxena (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden')))

All free accounts have restricted internet access, see this help page.