Unable to connect to internet URL behind firewall

  • Thread starter priyanka.khamankar
  • Start date
P

priyanka.khamankar

Hi,

I am using below two approaches to connect to read the content of internet url.
These two approaches work for me when the internet explorer session is open.

When the internet explorer window is closed, below code gives me 407 error.
I have also set the HTTP_PROXY environment variables as http://proxy-example.com:3128

Is there any way that the Python does not use Internet explorer proxy settings?
I want my python script to work even when the IE window is closed.Please help.

I am using Python version 2.6. Python code I am using is provide below.

Approach 1:
import urlib2

# == HTTP ==
#
# HTTP with auth info in ProxyHandler is working
#
proxy_handler = urllib2.ProxyHandler({'http': 'http://user:[email protected]:3128/'})
opener = urllib2.build_opener(proxy_handler)
response = opener.open('http://example.com/testpage.htm')
print response.read()

Approach 2:
# HTTP with AuthHandler is working
#
proxy_handler = urllib2.ProxyHandler({'http': 'http://proxy-example.com:3128/'})
proxy_auth_handler = urllib2.ProxyBasicAuthHandler()
proxy_auth_handler.add_password('realm', 'proxy-example.com:3128', 'user', 'pass')

opener = urllib2.build_opener(proxy_handler, proxy_auth_handler)
response = opener.open('http://example.com/testpage.htm')
print response.read()
 
V

Vytas D.

Hi,

My guess is that your firewall is blocking the connections. To check this,
disable your firewall and run your python program. If it runs, you have to
configure your firewall to allow your program to connect to the internet.

Vytas
 
S

Sven

Hi,

I am using below two approaches to connect to read the content of internet
url.
These two approaches work for me when the internet explorer session is
open.

When the internet explorer window is closed, below code gives me 407 error.
I have also set the HTTP_PROXY environment variables as
http://proxy-example.com:3128
From experience the environment variable name is in lowercase. Try
http_proxy instead.

Don't ask me why this environment variable is lowercase when most others
aren't.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top