Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from bs4 import BeautifulSoup
- import urllib.request
- import sys
- from threading import Thread
- import json
- count = 1
- threadnum = 0
- files = []
- def JsonWrite(file,alt):
- form = {'url':file, 'alt':alt}
- files.append(form)
- def JsonWritefile():
- f = open('names.json','w')
- json.dump(files,f)
- f.close()
- print('Downloaded!!!')
- sys.exit()
- def LoadImage(url,alt):
- global count
- filename = str(count)+'.png'
- count += 1
- url = "http:"+url
- f = open(filename,'wb')
- f.write(urllib.request.urlopen(url).read())
- f.close()
- JsonWrite(filename, alt)
- print("[+] {0} file loaded ({1})".format(filename,alt))
- def GetPictures(link):
- global count, threadnum
- print('Started thread%i'%threadnum)
- req = requests.get(link)
- soup = BeautifulSoup(req.text,'html.parser')
- images = soup.find_all("img", {"class":"grow-rotate"})
- if len(images)==0:
- print('ZERO LENGTH')
- for image in images:
- LoadImage(image.attrs['src'],image.attrs['alt'])
- threadnum-=1
- if __name__ == "__main__":
- if len(sys.argv)<2:
- print("Error: Type links 1-10 \n python scrapskins.py [link1] [link2] [link3] ...")
- sys.exit()
- for param in sys.argv[1:]:
- th = Thread(target=GetPictures, args=(param,))
- th.start()
- threadnum+=1
- while(threadnum!=0):
- pass
- JsonWritefile()
Add Comment
Please, Sign In to add comment