def lox(): pinterest = Pinterest(email='*****@*****.**', password='******', username='******', cred_root='logs/') search_batch = pinterest.search(query='neko chan', scope='pins') print(search_batch) neko = nekos.img(target='neko') print(neko)
cred_root = 'cred_root' pinterest = Pinterest(email=email, password=password, username=username, cred_root=cred_root) results = [] max_results = 100 batch_size = 50 query = 'food' # Due to recent changes in pinterest api we can't directly search for users. # instead we search for something else and extract pinners, owners and the relevant data search_batch = pinterest.search(scope='pins', query=query, page_size=batch_size) while len(search_batch) > 0 and len(results) < max_results: results += search_batch pinterest.search(scope='pins', query=query, page_size=batch_size) target_users = [] for s in results: target_users.append(s['owner']) # at this point target_users contains list of the user we want to invite. boards = [] board_batch = pinterest.boards() while len(board_batch) > 0: boards += board_batch
def download_image(url, path): r = requests.get(url=url, stream=True) if r.status_code == 200: with open(path, 'wb') as f: for chunk in r.iter_content(1024): f.write(chunk) pinterest = Pinterest(email='*****@*****.**', password='******', username='******', cred_root='cred_root') allpins = pinterest.search(scope='pins', query='something') images = [] for pin in allpins: origUrl = pin['images']['orig']['url'] images.append(origUrl) i = 0 for url in images: #indx = str(url).rfind('.') #extension = str(url)[indx:] #download_image(url, "img/" + str(i) + extension) response = requests.get(url) img = Image.open(BytesIO(response.content)) img = img.resize((224, 224)) img.save("img/" + str(i) + ".png", "PNG") i = i + 1