Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import re
- import subprocess
- site = 'https://2ch.hk'
- rx = r'/[^/]*?/src/\d+/\d+.\w{3,4}'
- def main(argv):
- if len(argv) < 2:
- print('Usage: python3 2chdd.py <link-to-thread>')
- return 1
- link = argv[1]
- proc = subprocess.Popen(['wget', '-O', '-', link], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
- page = proc.stdout.read().decode()
- proc.wait()
- links = set(re.findall(rx, page))
- with open('links.txt','w') as link_file:
- link_file.writelines([site+link+'\n' for link in links])
- proc = subprocess.run(['wget', '-nc', '-i', 'links.txt', '-q', '--show-progress'])
- return 0
- if __name__ == '__main__':
- import sys
- exit(main(sys.argv))
Add Comment
Please, Sign In to add comment