472,791 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,791 software developers and data experts.

Connecting to internet under proxy

Hi all.

I have a little script to connect to the internet and download some
files. I developed it in my house (direct connection) and it wordked
properly. But the problem is that in the office (under a proxy) it
doesn't run. My script is like:

import urllib
f=urllib.urlopen(SOME_WEB)
print f.read

I have tried to set the environmet variable
http_proxy="192.168.1.100:2929" and also:

import urllib
proxy={'http','http://192.168.1.100:2929'} and using
f=urllib.urlopen(SOME_WEB, proxy)
print f.read

the error was always the same:

(11001, 'getaddrinfo failed')
Any idea?? The proxy that we use is normally, in some programs I use a
tipical http proxy without authentification without problem.

Thanks in advanced.

Bye

Jul 24 '06 #1
2 10737
Chema wrote:
Hi all.

I have a little script to connect to the internet and download some
files. I developed it in my house (direct connection) and it wordked
properly. But the problem is that in the office (under a proxy) it
doesn't run. My script is like:

import urllib
f=urllib.urlopen(SOME_WEB)
print f.read

I have tried to set the environmet variable
http_proxy="192.168.1.100:2929" and also:

import urllib
proxy={'http','http://192.168.1.100:2929'} and using
f=urllib.urlopen(SOME_WEB, proxy)
print f.read

the error was always the same:

(11001, 'getaddrinfo failed')
Any idea?? The proxy that we use is normally, in some programs I use a
tipical http proxy without authentification without problem.

Thanks in advanced.
sholden@bigboy /c/colinux
$ export http_proxy="http://localhost:37004"

sholden@bigboy /c/colinux
$ python
Python 2.5b2 (trunk:50713, Jul 19 2006, 16:04:09)
[GCC 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
Started with C:/Steve/.pythonrc
>>import urllib
u = urllib.urlopen("http://www.holdenweb.com/")
OK, it works with an environment variable (I saw the access in my
mousehole proxy log). Now in a new shell:

sholden@bigboy ~
$ export | grep http

sholden@bigboy ~
$ python
Python 2.5b2 (trunk:50713, Jul 19 2006, 16:04:09)
[GCC 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
Started with C:/Steve/.pythonrc
>>import urllib
proxy = {'http': 'http://localhost:37004'}
u = urllib.urlopen("http://www.holdenweb.com/", proxies=proxy)
Yup. that worked too. Maybe it's just because you aren't making proxies
a keyword argument? If I try that (under cygwin) I see:
>>u = urllib.urlopen("http://www.holdenweb.com/", proxy)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.5/urllib.py", line 84, in urlopen
return opener.open(url, data)
File "/usr/local/lib/python2.5/urllib.py", line 192, in open
return getattr(self, name)(url, data)
File "/usr/local/lib/python2.5/urllib.py", line 327, in open_http
h.send(data)
File "/usr/local/lib/python2.5/httplib.py", line 707, in send
self.sock.sendall(str)
File "<string>", line 1, in sendall
TypeError: sendall() argument 1 must be string or read-only buffer, not dict

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

Jul 24 '06 #2
I don't know where is the problem, but I tried the same that you put
and it failed.

I tested it under cygwin, a cmd, linux with 2.2, 2.3 and 2.4 python
version. I think taht the problem is my corporate proxy. In this
sentences we use always a http proxy, but perhaps is not the suitable
kind of proxy. :-( I don't know, it is only an idea, 'cause in my other
programs I always use an http proxy and it work properly.

thank's for all.

Chema.

Jul 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: harry | last post by:
Hi, I have a program that runs on multiple client pc's. Occasionally one or more of those pc's use VPN to connect to another corporate network. When using VPN they need to set proxy server in...
1
by: Shweta | last post by:
Hi, I am trying to connect to esatblish FTP connection using WinInet APIs.I am on LAN connecting via proxy to internet. First call InternetOpen() is fine, however the call to InternetConnect()...
1
by: jbi130 | last post by:
I have a 3 tier client/server application where the client connection to the server which then uses PostgreSQL. I'd like to extend the client to have direct access to PostgreSQL but do not want to...
5
by: John | last post by:
Hi Does anyone have an example of using the Internet Transfer Control from behind a proxy server on port 8080? Thanks Regards
2
by: JezB | last post by:
I'm writing a windows forms application which accesses the internet at various points in two different ways: - calling a webservice (.wsdl), - using the WebRequest & WebResponse methods. I have...
0
by: Steve Podradchik | last post by:
Hi, We have a commercial app that downloads data from various Web pages (not via a Web Service, per se) and parses the data from the response. The code below works fine most of the time but, in...
3
by: chethana | last post by:
I am using copmaq ipaq pocket pc 2002 h3600 series. This device is synchronized with desk top pc running on windows 2000. I want this pocket pc to be conncted to internet .Kindly help ...
3
by: Wild Wind | last post by:
Hello all, I apologise in advance for the long windedness of this post, but I feel that if I am going to get any solution to this problem, it is important that I present as much information...
13
by: ShadowOfTheBeast | last post by:
Hi All, i have just written my first Webservice and client(windows form) but when i try to get a web references to the client to generate the proxy class on the client, i get an error this...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.