forked from markbookk/prntscrScraper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode-python3.py
54 lines (43 loc) · 1.91 KB
/
code-python3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#Credits to 'nazarpechka' for helping out with this code
import string, random, os, sys, _thread, httplib2, time
# from PIL import Image
if len(sys.argv) < 2:
sys.exit("\033[37mUsage: python3 " + sys.argv[0] + " (Number of threads)")
THREAD_AMOUNT = int(sys.argv[1])
print ("=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=\nThis script is for educational purposes only! Use on your own responsibility!\n=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=")
input("Press ENTER if you have read and accept that you are fully responsible for using this script!\n")
INVALID = [0, 503, 5082, 4939, 4940, 4941, 12003, 5556]
def scrape_pictures(thread):
while True:
#url = 'http://img.prntscr.com/img?url=http://i.imgur.com/'
url = 'http://i.imgur.com/'
length = random.choice((5, 6))
if length == 5:
url += ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(5))
else:
url += ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(3))
url += ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(3))
url += '.jpg'
# print (url)
filename = url.rsplit('/', 1)[-1]
# print (filename)
h = httplib2.Http('.cache' + thread)
response, content = h.request(url)
out = open(filename, 'wb')
out.write(content)
out.close()
file_size = os.path.getsize(filename)
if file_size in INVALID:
print("[-] Invalid: " + url)
os.remove(filename)
else:
print("[+] Valid: " + url)
for thread in range(1, THREAD_AMOUNT + 1):
thread = str(thread)
try:
_thread.start_new_thread(scrape_pictures, (thread,))
except:
print('Error starting thread ' + thread)
print('Succesfully started ' + thread + ' threads.')
while True:
time.sleep(1)