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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# -*- 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