Advertisement
Guest User

Untitled

a guest
Jun 8th, 2020
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. import re
  2. import sys
  3. import urllib
  4. import hashlib
  5. from urllib import request
  6.  
  7. hash_db = []
  8. for line in open(sys.argv[1], "r"):
  9.     if not re.search(sys.argv[2], line):
  10.         o = urllib.parse.urlparse(line.rstrip())
  11.  
  12.         if o.path.split('/')[-1]:
  13.             try:
  14.                 with request.urlopen(o.geturl()) as r:
  15.                     data = r.read()
  16.  
  17.                     print(o.geturl())
  18.  
  19.                     hash = hashlib.sha1(data).hexdigest()
  20.  
  21.                     if hash not in hash_db:
  22.                         with open(o.path.split('/')[-1], "wb") as f:
  23.                             f.write(data)
  24.                             f.close()
  25.                         hash_db.append(hash)
  26.                     else:
  27.             except urllib.error.HTTPError as e:
  28.                 continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement