faqts : Computers : Programming : Languages : Python : Snippets : Web Programming / Manipulating HTML files

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

6 of 9 people (67%) answered Yes
Recently 4 of 6 people (67%) answered Yes

Entry

Opening URLs

Jul 5th, 2000 10:01
Nathan Wallace, unknown unknown, Hans Nowak, Snippet 199, Martin von Loewis


"""
Packages: networking.internet
"""
"""
> Can anyone tell me how I can open a page given a URL? There seems to be
> very little documentation on urllib abd I haven't seen any examples. I
> have a CGI script which calls another CGI script. I would like this
> CGI script to call the CGI script it came from. Can anyone help? Thanks.
Please have a look at the urllib documentation, at
http://www.python.org/doc/current/lib/module-urllib.html
A simple example follows:
"""
import urllib
f=urllib.urlopen("http://www.python.org/")
s=f.readlines()
print s[0]
#'<HTML>\012'
print s[1]
#'<!-- THIS PAGE IS AUTOMATICALLY GENERATED.  DO NOT EDIT. -->\012'