getting a value from a web-page

Xavier Martínez xavim at fqingenieria.es
Thu Sep 25 03:57:49 EDT 2003


>Is it possible to get a row from a text-file? This text-file is located in a web page.

To get a file from a web server, you can use the 'urllib' module.  For instance:

>>> import urllib
>>> f = urllib.urlopen('http://www.google.com/robots.txt')

The object returned 'f', is file-like, i.e., you can 'read()', 'readline()', etc.  To get
line no.3, you can do:

>>> for i in range(3):
...     line = f.readline()
... 
>>> line
'Disallow: /groups\n'

>And a value from an excel located in a web-server? (Sheet1!cell A1)

You will probably need to download the excel file to a temporary file 
(you can use 'urllib', see 'tempfile' module for temporary files creation),
and then use Excel COM automation to get the sheet (for this, you can
ask at the python-win32 at python.org list.

Hope this helps.





More information about the Python-list mailing list