Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. import urllib.request as ur,re
  2. import os,sys
  3. thread = sys.argv[1]
  4.  
  5. url = ur.urlopen(thread)
  6.  
  7. str = url.read().decode('utf-8')
  8. pathtosrc=re.sub('.html','',re.sub('https://2ch.hk/b/res/','/b/src/',thread))+"/\d+.webm"
  9. pattern = re.compile('{}'.format(pathtosrc))
  10. files = list(set(pattern.findall(str)))
  11. directory = os.path.join(os.getcwd(), r'webm')
  12. if not os.path.exists(directory):
  13. os.makedirs(directory)
  14. for url in files:
  15. url='https://2ch.hk'+url
  16. path="webm/"+re.findall(r'\d+.webm',url)[0]
  17. ur.urlretrieve(url, path)
  18. print("Downloaded "+url+" to "+path)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement