Python Script node - Proxy issue

Hi,

 

I am having issue with proxy for the Python Script node. I setup the proxy in General - Network Connections and it works well for all the nodes except the Python Script node.

 

For testing, I connected to a network where no proxy is needed, and there the Python Script node works fine. However, it does not work from the network where proxy is required. (My Python script calls a few external URLs).

 

Are there any other config changes that I have to make, apart from the one I mentioned above. 

 

Thanks!

I think you'll have to set the proxy using the parameters provided for in whichever python package you're using, whether it's urllib2 or requests.

Thanks! I will try it out tomorrow and post an update here.

I solved it by using the below code in my script node: 

 

import urllib2

proxy = urllib2.ProxyHandler({'http': 'your proxy url here'})
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)

url = 'http://www.google.com'

html = urllib2.urlopen(url).read()

 

If there is a better way to do this, then please let me know :) 

1 Like

I solved it by using the below code in my script node: 

 

import urllib2

proxy = urllib2.ProxyHandler({'http': 'your proxy url here'})
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)

url = 'http://www.google.com'

html = urllib2.urlopen(url).read()

 

If there is a better way to do this, then please let me know :) 

1 Like