getting infos from a website

Zutroi Zatatakowski abou at cam.org
Sat Mar 30 14:27:03 EST 2002


Geoff Gerrietts wrote:
> 
> Check out urllib for retrieving the page:
>     http://www.python.org/doc/2.2p1/lib/module-urllib.html
> 
> Check out string and re for parsing the page to grab the stuff you
> want:
>     http://www.python.org/doc/2.2p1/lib/module-string.html
>     http://www.python.org/doc/2.2p1/lib/module-re.html
> 
> If that's not enough to get you productive, let me know where you're
> having specific stopping points.
> 
> --G.

Ok, I can now get the html source of the page I want. It stores it in a
file:

#! c:/python/python.exe

import urllib
import re

c = open('c:/python/tester', 'w')

f =
urllib.urlopen("http://www.coremud.org/cgi-bin/mycore.pl?stocks=1&font=Arial")

k =
urllib.urlretrieve("http://www.coremud.org/cgi-bin/mycore.pl?stocks=1&font=Arial",
'tester')

c.close()

# But then I'm trying to read the file and it never outputs what I ask:


raw_input('press Return->')

c = open('c:/python/tester', 'r')
c.read()

# readline(), read(), etc. don't seem to work because it doesn't output
the 'tester' file. In this example I close then reopen the file, but
even if I do not close it first, it doesn't output. Could it have
something to do with file permission? (even if I'm on windoze - the
'tester' file in an 'archive' file).
Anyone knows what I am doing wrong?


-- 
Zutroi Zatatakowski
Commando PACU
http://pacu.cjb.net




More information about the Python-list mailing list