Last active
March 9, 2023 21:32
-
-
Save jhorikawa/053b89bd6975f89f043871335dce8c5b to your computer and use it in GitHub Desktop.
Download Pinterest images from specific board using Python.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
how to get boardid
doesnt work
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what's the purpose of the accesstoken line and what is it ?