[Python]check_url_list.py

Leave a Comment
#!/usr/bin/env python
"""
Script to check a list of URLs (passed on stdin) for response code, and for response code of the final path in a series of redirects.
Outputs (to stdout) a list of count of a given URL, response code, and if redirected, the final URL and its response code

Optionally, with verbose flag, report on all URL checks on STDERR

Copyright 2013 Jason Antman  all rights reserved
This script is distributed under the terms of the GPLv3, as per the
LICENSE file in this repository.

The canonical version of this script can be found at:

"""

import sys
import urllib2

def get_url_nofollow(url):
    try:
        response = urllib2.urlopen(url)
        code = response.getcode()
        return code
    except urllib2.HTTPError as e:
        return e.code
    except:
        return 0

def main():
    urls = {}

    for line in sys.stdin.readlines():
        line = line.strip()
        if line not in urls:
            sys.stderr.write("+ checking URL: %s\n" % line)
            urls[line] = {'code': get_url_nofollow(line), 'count': 1}
            sys.stderr.write("++ %s\n" % str(urls[line]))
        else:
            urls[line]['count'] = urls[line]['count'] + 1

    for url in urls:
        if urls[url]['code'] != 200:
            print "%d\t%d\t%s" % (urls[url]['count'], urls[url]['code'], url)

if __name__ == "__main__":
    main()

0 comments:

Post a Comment

Powered by Blogger.
Warning: include(4.php) [function.include]: failed to open stream: No such file or directory in PATH on line 3

Microsoft SQL Native Client error '80040e14
Unclosed quotation mark after the character string
Query failed: ERROR: syntax error at or near \"'\" at character 56 in home/www/regs/home.php on line 121.
SQLSTATE: 42000 (ER_SYNTAX_ERROR) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
ORACLE-00933: SQL command not properly ended
function antiscanner($antiscanner)
{
return \$antiscanner;
}
\"/usr/local/bin\"
\"c:/www/regs/home\"
define( 'DB_NAME', 'database' );
define( 'DB_USER', 'www.localhost.com' );
define( 'DB_PASSWORD', 'antiscanner' );
define( 'DB_HOST', 'localhost' );
define( 'DB_CHARSET', 'utf8' );
root:!:0:0::/:/usr/bin/ksh daemon:!:1:1::/etc:bin:!:2:2::/bin:sys:!:3:3::/usr/sys: adm:!:4:4::/var/adm:uucp:!:5:5::/usr/lib/uucp: guest:!:100:100::/home/guest:
SomeCustomInjectedHeader:injected_by_wvs
PROJECTS
Raven
DevAssistant
Pascal Trainer
Meow encoder 0.2
PROJECT LIST
TOOLS
Hacking
Forensic
Developer tools
Reverse engineering
APP LIST
DOCUMENTS
Hacking
Metasploit
Coding
Web development
SOURCE CODE
C#, VB.NET C++ Delphi VB6
Python PHP Perl Bash Batch
HTML, CSS, Javascript
Autoit AHK