#!/usr/local/bin python
"""
This script is used to check urls with a pattern. The configuration file has following format
protocol_name|url|additional_args
example:
simpleGET|http://www.google.com/|Google
simpleGET|http://www.aol.com/|WhatWhat
Example output:
http://www.google/ -> True
http://www.aol.com/ -> False
"""
import os.path, re, getopt, sys, urllib2, urllib
verbose = False
FETCHER = 'fetcher'
MATCHER = 'matcher'
def say(s):
if verbose:
print s
class UrlChecker:
def __init__(self, urls, protocols):
self.urls = urls
self.protocols = protocols
def check(self):
for rurl in self.urls:
self._check_url(rurl)
def _check_url(self, rurl):
protocol, url, args = rurl.split('|')
say("Check URL %s with protocol %s. Args = %s" % (url, protocol, args))
rslt = self.protocols[protocol][FETCHER](url, args)
self.protocols[protocol][MATCHER](rslt, url, args)
def load_urls(urlfile):
urls = []
f = open(urlfile, 'r')
try:
for line in f:
say("Load one raw url %s" % (line.strip()))
urls.append(line.strip())
finally:
f.close()
return urls
def add_simpleGET(protocols):
def simple_get(url, ignore):
r = urllib2.urlopen(url)
rslt = r.read()
r.close()
return rslt
def str_match(body, url, pattern):
print "%s -> %s" % (url, body.find(pattern) != -1)
protocols['simpleGET'] = {FETCHER : simple_get, MATCHER : str_match}
def init_protocols():
protocols = {};
add_simpleGET(protocols)
return protocols
if __name__ == '__main__':
def usage():
print "Usage:"
print "python check_url.py -f <url_file> -v"
try:
opts, args = getopt.getopt(sys.argv[1:], "f:v")
except getopt.GetoptError:
usage()
sys.exit(2)
urls = None
protocols = init_protocols()
for opt, arg in opts:
if opt in ("-v"):
verbose = True
elif opt in ("-f"):
urls = load_urls(arg)
if urls is None:
usage()
sys.exit(1)
checker = UrlChecker(urls, protocols)
checker.check()
2008-02-08
Web page smoke test script
Subscribe to:
Post Comments (Atom)
8 comments:
Surwit shows that: "stress management techniques, when added to standard care, helped reduce glucose levels".
In addition, cognitive behavioral therapy may be offered or
group therapy. In cases of mild depression medicines
show a good recovery in the patient.
Look at my website ... clinical depression
mc75 software http://buyoemsoftware.co.uk/it/product-37146/The-Palette-Melody-Composing-Tool-4-4 gps cell phone locator software free [url=http://buyoemsoftware.co.uk/it/product-35664/Adobe-InDesign-Server-CS5-5-7-5-Multilingual]sharewa re business card software[/url] oscar consumer services software
[url=http://buyoemsoftware.co.uk/product-37094/Mediachance-Dynamic-Auto-Painter-2-5]Mediachance Dynamic Auto-Painter 2.5 - Software Store[/url] telus dsl-604 gca software
[url=http://buyoemsoftware.co.uk/de/product-37321/Ultra-Mobile-3GP-Video-Converter-4-3][img]http://buyoem.co.uk/image/7.gif[/img][/url]
dvd encription removal software http://buysoftwareonline.co.uk/it/product-37131/RAC-Server-3-3 computer software tucson [url=http://buysoftwareonline.co.uk/es/news-34/Internet-Explorer-9-Microsoft-gives-first-glimpse-of-new-browser]willow creek software[/url] tax preperation software reviews
[url=http://buysoftwareonline.co.uk/es/category-100-109/Antivirus-y-seguridad]Antivirus y seguridad - Software Store[/url] ble program software writing
[url=http://buysoftwareonline.co.uk/es/product-37133/Reohix-Fresh-Ram-4-5][img]http://buyoem.co.uk/image/6.gif[/img][/url]
always i used to read smaller articles that also clear their motive,
and that is also happening with this piece of
writing which I am reading here.
Look at my web blog ultracelebdiet.org
you are in reality a good webmaster. The website loading pace is amazing.
It kind of feels that you are doing any unique trick. In addition, The
contents are masterpiece. you've performed a wonderful task in this subject!
my web blog; Raspberry Ketones Max
[url=http://certifiedpharmacy.co.uk/products/minocin.htm][img]http://onlinemedistore.com/4.jpg[/img][/url]
guardian pharmacy little current http://certifiedpharmacy.co.uk/products/vantin.htm cvs and pharmacy [url=http://certifiedpharmacy.co.uk/catalogue/g.htm]state pharmacy laws[/url]
pharmacy technician schools in georgia http://certifiedpharmacy.co.uk/catalogue/z.htm pharmacy thorndale pa [url=http://certifiedpharmacy.co.uk/products/exelon.htm]exelon[/url]
thrifty pharmacy new york http://certifiedpharmacy.co.uk/products/rave--energy-and-mind-stimulator-.htm how to write a pharmacy school admission essay [url=http://certifiedpharmacy.co.uk/products/leukeran.htm]herbal pharmacy houston texas[/url]
iloilo doctors hospital pharmacy http://certifiedpharmacy.co.uk/products/cialis-soft-tabs.htm pondimin from mexican online pharmacy [url=http://certifiedpharmacy.co.uk/products/prednisolone.htm]prednisolone[/url]
[url=http://englandpharmacy.co.uk/products/glucophage.htm][img]http://onlinemedistore.com/10.jpg[/img][/url]
clap your hands and say yeah pharmacy http://englandpharmacy.co.uk/products/naprosyn.htm bradens professional pharmacy [url=http://englandpharmacy.co.uk/products/terramycin.htm]history of pharmacy law[/url]
weight loss patch online pharmacy http://englandpharmacy.co.uk/products/keftab.htm allegra online pharmacy [url=http://englandpharmacy.co.uk/products/confido.htm]confido[/url]
creech and gibbs pharmacy http://englandpharmacy.co.uk/products/prilosec.htm pharmacy sale abbeville [url=http://englandpharmacy.co.uk/products/ed-discount-pack-2.htm]cals pharmacy snowbords[/url]
the lines of communication within a pharmacy http://englandpharmacy.co.uk/products/altace.htm help studying for pharmacy tech [url=http://englandpharmacy.co.uk/categories/erection-packs.htm]erection packs[/url]
dating abusr http://loveepicentre.com/contact/ body hair dating personals
dating san francisco [url=http://loveepicentre.com/]we are dating now[/url] free dating software and installation
dating and seattle [url=http://loveepicentre.com/faq/]mystery says online dating[/url] is gay model john stallings dating [url=http://loveepicentre.com/user/shogun6969/]shogun6969[/url] video dating game seneros
Post a Comment