Guest User

2chdd.py

a guest
Dec 19th, 2023
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3.  
  4. import re
  5. import subprocess
  6.  
  7.  
  8. site = 'https://2ch.hk'
  9. rx = r'/[^/]*?/src/\d+/\d+.\w{3,4}'
  10.  
  11. def main(argv):
  12.     if len(argv) < 2:
  13.         print('Usage: python3 2chdd.py <link-to-thread>')
  14.         return 1
  15.  
  16.     link = argv[1]
  17.  
  18.     proc = subprocess.Popen(['wget', '-O', '-', link], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
  19.  
  20.     page = proc.stdout.read().decode()
  21.     proc.wait()
  22.  
  23.     links = set(re.findall(rx, page))
  24.  
  25.     with open('links.txt','w') as link_file:
  26.         link_file.writelines([site+link+'\n' for link in links])
  27.  
  28.     proc = subprocess.run(['wget', '-nc', '-i', 'links.txt', '-q', '--show-progress'])
  29.  
  30.     return 0
  31.  
  32.  
  33. if __name__ == '__main__':
  34.     import sys
  35.     exit(main(sys.argv))
Add Comment
Please, Sign In to add comment