# -*- coding: utf8 -*-
from WebDAV import client
import urlparse
import sys
from urllib import unquote
from BeautifulSoup import *
out = []
#####################################################
def parseLinks(xml):
"""Parse the given xml page """
global out
soup = BeautifulSoup(xml)
for record in soup('a:href'):
link = unquote(record.renderContents())
if re.search("/$", link):
chain(link)
else:
pass
out.append((link))
return
def chain(URL):
res = client.Resource(URL)
response = res.propfind(url=URL, depth=1)
parseLinks(response.get_body())
########################################
_url = sys.argv[1:2]
if not _url:
sys.stderr.write("""usage: %s url
where url refers to a WebDAV enabled location.
""" % sys.argv[0])
sys.exit(1)
#
_t = urlparse.urlparse(_url[0])
SCHEME=_t[0].lower()
SERVER=_t[1]
TEST_URL = _url[0]
del _t
del _url
del sys.argv[1]
chain(TEST_URL)
if out:
for l in out:
print l