/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
# if you are on the internet you can access the HTML code of a # given web site # using the urlopen() method/function from the module urllib2 Â import urllib2 Â urlStr = 'http://www.python.org/' try: fileHandle = urllib2.urlopen(urlStr) str1 = fileHandle.read() fileHandle.close() print '-'*50 print 'HTML code of URL =', urlStr print '-'*50 except IOError: print 'Cannot open URL %s for reading' % urlStr str1 = 'error!' Â print str1
URL: http://www.daniweb.com/forums/thread31148.html