Skip to content

Instantly share code, notes, and snippets.

@jhorikawa
Last active March 9, 2023 21:32
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save jhorikawa/053b89bd6975f89f043871335dce8c5b to your computer and use it in GitHub Desktop.
Save jhorikawa/053b89bd6975f89f043871335dce8c5b 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()
@ouss19951995
Copy link

what's the purpose of the accesstoken line and what is it ?

@woshichuanqilz
Copy link

how to get boardid

@lowlune
Copy link

lowlune commented Aug 27, 2020

doesnt work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment