Advertisement
YASSINOXTN

Pinterest grabber

Feb 7th, 2017
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import urllib2, urllib
  4. import re
  5. import random, os
  6.  
  7.  
  8. def bring(category, maxb, stacki):
  9.     try:
  10.         i = 0
  11.         if(os.path.exists(category) == False):
  12.             os.makedirs(category)
  13.         data = urllib2.urlopen("https://www.pinterest.com/search/pins/?q="+str(category)+str(stacki)).read()
  14.         search = re.findall('href="/pin/(.*?)/"', data)
  15.         for pin in search:
  16.             data = urllib2.urlopen("https://www.pinterest.com/pin/"+str(pin)+"/").read()
  17.             check = re.findall('src="(.*?)"', data)
  18.             for c in check:
  19.                 if(".jpg" in c and "avatars" not in c and "564x" in c):
  20.                     if(i < int(maxb)):
  21.                         urllib.urlretrieve(c, str(category)+"/"+str(random.random())+".jpg")
  22.                         i += 1
  23.     except:
  24.         pass
  25.  
  26. category = raw_input("Search >")
  27. max_bring = raw_input("Max >")
  28. stacks = raw_input("Number of stacks >")
  29. bring(category, max_bring, "")
  30. for _ in range(0, int(stacks)):
  31.     bring(category, max_bring, "+"+str(_))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement