import io import requests import getpass from lxml import html # Get login details username = input('Username: ') password = getpass.getpass('Password: ') # Get list of all pages url = 'http://wiki.wrl.unsw.edu.au/index.php' page = requests.get(url + '/Special:Allpages', auth=(username, password)) tree = html.parse(io.BytesIO(page.content)) # Save page names elements = tree.xpath('*//td/a')[1:] with open('pages.txt', 'w') as f: for e in elements: f.write(e.text + '\n')