getting infos from a website
cliechti at gmx.net
Sat Mar 30 22:37:49 CET 2002
Zutroi Zatatakowski <abou at cam.org> wrote in
news:mailman.1017516408.9897.python-list at python.org:
> Geoff Gerrietts wrote:
> Ok, I can now get the html source of the page I want. It stores it in
> a file:
> c = open('c:/python/tester', 'w')
you're opening the file for write only. use 'w+' for read-write
access. don't forget to use c.seek() to reposition the file pointer
if you want to read what you've just written.
> f =
here you get a file like object from which you can retreive the data.
e.g "print f.read()"
> k =
> ont=Arial", 'tester')
this creates a file named "tester" your file opened and bound to c
would be in confilct with that file if it were in the same directory
so you don't need c.
either you use f or k but you don't need both.
> # But then I'm trying to read the file and it never outputs what I
because urlretrieve created its own file in the current directory.
> raw_input('press Return->')
> c = open('c:/python/tester', 'r')
> # 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?
Chris <cliechti at gmx.net>
More information about the Python-list