Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import argparse
- import requests
- import time
- import math
- from threading import Thread
- from random import choice
- from random import randint
- from string import digits
- from sys import exit
- symbdict = 'abcdf' + digits
- def genp():
- return ''.join(choice(symbdict) for i in range(randint(4, 6)))
- parser = argparse.ArgumentParser(description='GOSMS downloader 2.0')
- parser.add_argument('-c', action="store", dest="count", default=5, type=int)
- parser.add_argument('-o', action="store", dest="out", default='')
- parser.add_argument('-t', action="store", dest="threads", default=1, type=int)
- args = parser.parse_args()
- count = args.count
- tcount = args.threads
- path = args.out
- if path != '' and path[len(path):] != '\\':
- path = path + '\\'
- if tcount > count:
- print("The count of threads should not exceed the url's count")
- exit()
- class dlThread(Thread):
- def __init__(self, task):
- Thread.__init__(self)
- self.task = task
- def run(self):
- for self.i in range(self.task):
- self.gen = genp()
- self.url = 'https://gs.3g.cn/D/' + self.gen + '/c'
- self.response = requests.get(self.url)
- if self.response.url != self.url and self.response.status_code == 200:
- self.url = self.response.url
- self.f = open(path + self.gen + self.url[self.url.find('.', self.url.find('com/')):], 'wb')
- self.f.write(self.response.content)
- self.f.close()
- print(self.gen + " downloaded")
- else:
- print(self.gen + "is error!")
- threads = []
- rest = count
- for i in range(tcount):
- if rest >= 0:
- threads.append(dlThread(math.ceil(count/tcount)))
- else:
- threads.append(dlThread(rest + math.ceil(count/tcount)))
- threads[i].start()
- # Coded by MorphEdAlign
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement