#!/usr/bin/env python import getpass from subprocess import Popen, list2cmdline import sys import splinter def fill_password(b, username=None, password=None): if not username: username = getpass.getpass('username: ') if not password: password = getpass.getpass('password: ') b.fill('username', username) b.fill('password', password) b.find_by_name('submit').click() def main(url, username=None): b = splinter.Browser() try: #url = 'https://mail.gnome.org/mailman/private/board-list/' b.visit(url) if 'Password' in b.html: fill_password(b, username=username) links = [l['href'] for l in b.find_link_by_partial_text('Text')] cookie = b.driver.get_cookies()[0] cookie_name = cookie['name'] cookie_value = cookie['value'] cookie_str = "Cookie: {name}={value}".format(name=cookie_name, value=cookie_value) wget_cookie_arg = '--header={0}'.format(cookie_str) #print wget_cookie_arg b.quit() for link in links: #print link cmd = ['wget', wget_cookie_arg, link] print list2cmdline(cmd) # pipe that to "parallel -j 8" except: b.quit() if __name__ == '__main__': site = sys.argv[1] user = sys.argv[2] if site.startswith('http'): url=site else: url = 'https://mail.gnome.org/mailman/private/{0}'.format(site) main(username=user, url=url)