coding utf8 from WebDAV import client import urlparse import sys from

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- 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):
try:
res = client.Resource(link)
response = res.propfind(url=link, depth=1)
self.get_links(response.get_body())
except:
pass
if len(sys.argv) != 2:
sys.stderr.write("""usage: %s url\nwhere url refers to a WebDAV enabled location.\n""" % sys.argv[0])
sys.exit(1)
Huita(sys.argv[1])