1 2 3 4 5 6 7 8 9 10
|
>>> import urllib2
>>> page = urllib2.urlopen("http://www.python.org")
>>> page.info().headers
['Date: Tue, 16 Dec 2008 21:36:56 GMT\r\n', 'Server: Apache/2.2.3 (Debian) DAV/2 SVN/1.4.2 mod_ssl/2.2.3 OpenSSL/0.9.8c mod_wsgi/2.3 Python/2.4.4\r\n', 'Last-Modified: Tue, 16 Dec 2008 16:12:12 GMT\r\n', 'ETag: "105800d-3f5e-38d68f00"\r\n', 'Accept-Ranges: bytes\r\n', 'Content-Length: 16222\r\n', 'Connection: close\r\n', 'Content-Type: text/html; charset=UTF-8\r\n']
>>> contenu = page.read()
>>> page.close()
>>> fichier = open("/home/login/test.html", 'w')
>>> fichier.write(contenu)
>>> fichier.close() |
Partager