Create CheckSiteStatus.py

'''
Created on Feb 4, 2013

This module can be called to check the availability of a website.
You must pass it the following variables:
  'url'         - this is the full url of the site in question (i.e. "http://www.google.com").
  'userAgent'   - this is an optional variable. Either leave it blank or pass it a User Agent 
                  string (i.e. '' or 'Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20100101 Firefox/5.02').
                  User Agent must be valid. Validity is determined by comparison to list of known User 
                  Agents located in def _agents.
                  
This module returns an object (SiteInfo) with the following attributes:
    agentUsed
    code
    url
    message
    redirectLocation
    siteStatus
    
This module can be called as follows:
x = checkWebsite()
locations = ["http://www.playboy.com", "http://www.python.org/idontexist.html", "http://www.bit.ly/GVBQJS", "http://goo.gl/sOhl", "http://www.google.com"]
for url in locations:
    mysiteInfo = x.checkSite(url)
    print mysiteInfo.agentUsed
    print mysiteInfo.code
    print mysiteInfo.url
    print mysiteInfo.message
    print str(mysiteInfo.redirectLocation)
    print mysiteInfo.siteStatus
    print "============================================"
    
Below are four samples of the return (for the instance above):
Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0
302
http://www.playboy.com
Moved Temporarily
http://10.0.0.100:15871/BlockedPerCompanyWebFilter.html
2
============================================
Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0
404
http://www.python.org/idontexist.html
Not Found
None
1
============================================
Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0
301
http://www.bit.ly/GVBQJS
Moved Permanently
http://bit.ly/GVBQJS
2
============================================
Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0
301
http://goo.gl/sOhl
Moved Permanently
http://en.wikipedia.org/wiki/Lamborghini_Countach
2
============================================
Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0
200
http://www.google.com
OK
None
0
============================================

    
@author: Nephos
'''