# -*- coding: utf8 -*-
from WebDAV import client
import urlparse
import sys
from urllib import unquote
from BeautifulSoup import *
class Huita:
def __init__(self, link):
self.link = link
self.links = []
self.chain(link)
def get_links(self, xml):
soup = BeautifulSoup(xml)
for record in soup('a:href'):
link = unquote(record.renderContents())
if link not in self.links:
self.links.append(link)
self.chain(link)
print link
def chain(self, link):
res = client.Resource(link)
response = res.propfind(url=link, depth=1)
self.get_links(response.get_body())
def result(self):
print self.links
_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]
response = Huita(TEST_URL)
print response.result()