All pastes #1036966 Raw Edit

Unnamed

public python v1 · immutable
#1036966 ·published 2008-06-02 16:16 UTC
rendered paste body
#!/usr/bin/pythonimport urllib, urllib2from urlparse import urlparsefrom sgmllib import SGMLParserclass FetchLinks(SGMLParser):	def reset(self):		SGMLParser.reset(self)		self.urls = []	def start_a(self, attrs):		href = [v for k, v in attrs if k=='href']openURL = urllib.urlopen('http://guide.real.com')fetchURLs = FetchLinks()fetchURLs.feed(openURL.read())openURL.close()fetchURLs.close()#URL = 'http://guide.real.com'for URL in fetchURLs.urls:	try:		urllib2.urlopen(URL)		print 'Opening link ' % URL	except urllib2.HTTPError, e:		if e.code == 401:			print 'Not Authorized'		if e.code == 404:			print 'Not Found'		if e.code == 503:			print 'Service Unavailable'	else:		print 'Success'