Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import urllib2, urllib
- import re
- import random, os
- def bring(category, maxb, stacki):
- try:
- i = 0
- if(os.path.exists(category) == False):
- os.makedirs(category)
- data = urllib2.urlopen("https://www.pinterest.com/search/pins/?q="+str(category)+str(stacki)).read()
- search = re.findall('href="/pin/(.*?)/"', data)
- for pin in search:
- data = urllib2.urlopen("https://www.pinterest.com/pin/"+str(pin)+"/").read()
- check = re.findall('src="(.*?)"', data)
- for c in check:
- if(".jpg" in c and "avatars" not in c and "564x" in c):
- if(i < int(maxb)):
- urllib.urlretrieve(c, str(category)+"/"+str(random.random())+".jpg")
- i += 1
- except:
- pass
- category = raw_input("Search >")
- max_bring = raw_input("Max >")
- stacks = raw_input("Number of stacks >")
- bring(category, max_bring, "")
- for _ in range(0, int(stacks)):
- bring(category, max_bring, "+"+str(_))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement