Skip to content

Instantly share code, notes, and snippets.

@vodp
Forked from jhorikawa/getPinterestBoardPins.py
Created September 15, 2017 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vodp/3c1b68002ef6633bbe2e3c836fcce85f to your computer and use it in GitHub Desktop.
Save vodp/3c1b68002ef6633bbe2e3c836fcce85f to your computer and use it in GitHub Desktop.
Download Pinterest images from specific board using Python.
import pprint
import requests
import os
from urllib.request import urlopen
accessToken = "xxxxxxxxxx"
boardId = "0000000000"
folderPath = "./images"
response = requests.get(
'https://api.pinterest.com/v3/boards/'+boardId+'/pins/',
params={'access_token':accessToken,
'fields':'pin.images[750x],pin.description,pin.image_signature',
'page_size':100
})
if(os.path.isdir(folderPath) == False):
os.makedirs(folderPath)
imageDatas = response.json()['data']
for imageData in imageDatas:
pprint.pprint(imageData)
imageUrl = imageData['images']['750x']['url']
imageDesc = imageData['description']
imageSig = imageData['image_signature']
extensions = imageUrl.split('.')
extension = extensions[len(extensions)-1]
f = open(folderPath+"/"+imageSig+"."+extension,'wb')
f.write(urlopen(imageUrl).read())
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment