urllib function

Jim Richardson warlock at eskimo.com
Tue May 6 01:54:52 EDT 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, 04 May 2003 12:30:12 +0000,
 Robin Karpeta <rmkarp at karfaz.nildram.co.uk> wrote:
> Hi,
> I wrote some code that 'screenscrapes' stuff from websites.  I have been 
>   running this on Red Hat Linux 7.3 and now 9.0, with the same results.
> 
> Here is the code that reads the data from the URL, it will read from the 
> URL in variable u and write to the file whose name is held in variable fn:
> 
> def read_one_pic(u, fn):
> 	data = urllib.urlopen(u).read()
> 	f = open(fn,'w')
> 	f.write(data)
> 	f.close	
> 
> Under Python 1.5 this has always worked perfectly, however under later 
> versions (2.1, 2.2) although the code still works it is VERY slow.  When 
> I ran tcpdump I noticed that while there were no visible error messages 
> under Python 1.5, und:wer the later versions there were many entries like 
> the one below:
> 
> 11:09:47.617396 db2.home.sys > radius.nildram.co.uk: icmp: db2.home.sys 
> udp port 32806 unreachable [tos 0xc0]
> 
> I have been through the manuals but have not found anything relating to 
> this.  I am probably not aware of something really simple, but would 
> appreciate help on this.
> 
> Many thanks
> Robin
> 



I can't help with your problem, but is there a reason you aren't using
urlretrieve?  I found it more useful tp me, but my needs may be
different than yours. 


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+t04sd90bcYOAWPYRAkSUAJ4qNJJFB3KFVRWM5UUBsCD3blskJACeNPt3
5os6wyJID2z/Ukc0NGD0FuM=
=ClQk
-----END PGP SIGNATURE-----

-- 
Jim Richardson         http://www.eskimo.com/~warlock

Linux, because eventually, you grow up enough to be trusted with a fork()




More information about the Python-list mailing list