Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib.request as ur,re
- import os,sys
- thread = sys.argv[1]
- ext = sys.argv[2]
- url = ur.urlopen(thread)
- str = url.read().decode('utf-8')
- pathtosrc=re.sub('.html','',re.sub('https://2ch.hk/b/res/','/b/src/',thread))+"/\d+."+ext
- pattern = re.compile('{}'.format(pathtosrc))
- files = list(set(pattern.findall(str)))
- directory = os.path.join(os.getcwd(), ext)
- if not os.path.exists(directory):
- os.makedirs(directory)
- for url in files:
- url='https://2ch.hk'+url
- path= ext+"/"+re.findall(r'\d+.{0}'.format(ext),url)[0]
- ur.urlretrieve(url, path)
- print("Downloaded "+url+" to "+path)
Advertisement
Add Comment
Please, Sign In to add comment