Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Author: Ephexeve M
Date: Mon May 21 11:48:10 CEST 2012
System: Unix
import pages
from sys import argv, exit
import httplib
import socket
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-w", "--write", dest = "filename", help = "write report to file", metavar = "FILE")
(options, args) = parser.parse_args()
class GetPages:
def __init__(self):
try: = argv[1]
except IndexError as error:
print "\nError, where is the link? -- %s" % error
self.write = argv[2] if len(argv) >= 3 else False
self.filename = argv[3] if len(argv) >= 4 else False
self.checkSite = self.checkSite()
def checkSite(self):
if not"www."): = "www." +
for pagelinks in pages.links:
pagelinks = pagelinks.replace("\n", "") ; pagelinks = "/" + pagelinks
host = + pagelinks
site_connection = httplib.HTTPConnection(
site_connection.request("GET", host)
response = site_connection.getresponse()
if response.status:
print "%s Status: %s" % (host, response.status)
if self.write:
for status in response.status:
with open(self.filename, "w") as data:
data.write(host + "--" + status + "\n")
except Exception as error:
return "Error occured: %s" % error
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.