Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #49219

Proxy connection with Python

Date 2013-06-26 12:54 +1200
Subject Proxy connection with Python
From bevan jenkins <bevan07@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3869.1372208062.3114.python-list@python.org> (permalink)

Show all headers | View raw


Hello,

I have an issue that has been frustrating me for a while now.

This is an update of a crosspost
(http://stackoverflow.com/questions/16703936/proxy-connection-with-python)
which I made over a month ago.

I have been attempting to connect to URLs from python. I have tried:
urllib2, urlib3, and requests. It is the same issue that i run up
against in all cases. Once I get the answer I imagine all three of
them would work fine.

The issue is connecting via proxy. I have entered our proxy
information but am not getting any joy. I am getting 407 codes and
error messages like: HTTP Error 407: Proxy Authentication Required (
Forefront TMG requires authorization to fulfill the request. Access to
the Web Proxy filter is denied. )

I think that this also stops me using pip to install (at least from
remotes ).  I get 'Cannot fetch index base URL
http://pypi.python.org/simple/".  I end up using git to clone a local
copy of the repo and install from that.

However, I can connect using a number of other applications that go
through the proxy, git and pycharm for example. When I run git config
--get htpp.proxy it returns the same values and format that I am
entering in Python namely:

http://username:password@proxy:8080

An example of code in requests is

import requests
proxy = {"http": "http://username:password@proxy:8080"}
url = 'http://example.org'
r = requests.get(url,  proxies=proxy)
print r.status_code

Thanks for your time and any suggestions gratefully received.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Proxy connection with Python bevan jenkins <bevan07@gmail.com> - 2013-06-26 12:54 +1200

csiph-web