nicholas@3140: #!/usr/bin/python nicholas@3140: nicholas@3140: import xml.etree.ElementTree as ET nicholas@3140: import os nicholas@3140: import sys nicholas@3140: from lxml import html nicholas@3140: import requests nicholas@3140: nicholas@3140: nicholas@3140: url = input('Where is the remote WAET URL? ') nicholas@3140: output = input('Where am I saving all these? (Provide the full path using pwd to the saves directory) ') nicholas@3140: if output.endswith('/') == False: nicholas@3140: output = output + '/' nicholas@3140: if url.endswith('/saves/') == False and url.endswith('/saves') == False: nicholas@3140: if url.endswith('/') == False: nicholas@3140: url = url + '/' nicholas@3140: url = url + 'saves' nicholas@3140: print(url) nicholas@3140: page = requests.get(url) nicholas@3140: tree = html.fromstring(page.content) nicholas@3140: print(tree) nicholas@3140: ahref = tree.xpath('//a/text()') nicholas@3140: for a in ahref: nicholas@3140: if a.endswith('.xml'): nicholas@3140: r = requests.get(url+a, allow_redirects=True) nicholas@3140: open(output+a, 'wb').write(r.content) nicholas@3140: print(ahref)