2000-02-26 10:24:46 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
|
|
import re,cgi,sys,urlparse,time,os
|
|
|
|
|
|
|
|
|
|
# configuration
|
|
|
|
|
sys.stderr = sys.stdout
|
2000-03-08 12:01:51 +00:00
|
|
|
dist_dir = "/home/calvin/projects/linkchecker"
|
2000-02-26 10:24:46 +00:00
|
|
|
sys.path.insert(0,dist_dir)
|
2000-03-26 18:53:23 +00:00
|
|
|
cgi.logfile = "linkchecker.log" # must be an existing file
|
2000-03-08 12:01:51 +00:00
|
|
|
# end configuration
|
2000-02-26 10:24:46 +00:00
|
|
|
|
|
|
|
|
def testit():
|
|
|
|
|
cgi.test()
|
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
2000-03-08 12:01:51 +00:00
|
|
|
import linkcheck
|
|
|
|
|
|
2000-02-26 10:24:46 +00:00
|
|
|
# main
|
|
|
|
|
print "Content-type: text/html"
|
2000-03-08 12:01:51 +00:00
|
|
|
print "Cache-Control: no-cache"
|
2000-02-26 10:24:46 +00:00
|
|
|
print
|
|
|
|
|
#testit()
|
|
|
|
|
form = cgi.FieldStorage()
|
2000-03-26 18:53:23 +00:00
|
|
|
if not linkcheck.lc_cgi.checkform(form):
|
2000-03-27 13:34:31 +00:00
|
|
|
linkcheck.lc_cgi.logit(form, form)
|
2000-03-26 18:53:23 +00:00
|
|
|
linkcheck.lc_cgi.printError(sys.stdout)
|
2000-02-26 10:24:46 +00:00
|
|
|
sys.exit(0)
|
2000-03-08 12:01:51 +00:00
|
|
|
config = linkcheck.Config.Configuration()
|
|
|
|
|
config["recursionlevel"] = int(form["level"].value)
|
|
|
|
|
config["log"] = linkcheck.Logging.HtmlLogger()
|
|
|
|
|
if form.has_key("anchors"): config["anchors"] = 1
|
|
|
|
|
if not form.has_key("errors"): config["verbose"] = 1
|
2000-02-26 10:24:46 +00:00
|
|
|
if form.has_key("intern"):
|
2000-03-26 18:53:23 +00:00
|
|
|
config["internlinks"].append(re.compile("^(ftp|https?)://"+\
|
|
|
|
|
linkcheck.lc_cgi.getHostName(form)))
|
2000-02-26 10:24:46 +00:00
|
|
|
else:
|
2000-03-08 12:01:51 +00:00
|
|
|
config["internlinks"].append(re.compile(".+"))
|
|
|
|
|
# avoid checking of local files
|
|
|
|
|
config["externlinks"].append((re.compile("^file:"), 1))
|
2000-02-26 10:24:46 +00:00
|
|
|
|
2000-03-08 12:01:51 +00:00
|
|
|
# start checking
|
|
|
|
|
config.appendUrl(linkcheck.UrlData.GetUrlDataFrom(form["url"].value, 0))
|
|
|
|
|
linkcheck.checkUrls(config)
|