Welcome, guest | Sign In | My Account | Store | Cart

Batch download all the pinned pictures in your Pinterest board to a local folder. Be noted: you have to keep your internet browser signed in your Pinterest account first.

Python, 38 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# -*- coding: utf-8 -*-
"""
Batch download all the pinned pictures in your Pinterest board to a local folder.
Be noted: you have to keep your internet browser signed in your Pinterest account first.
Please contact me @ alfred.hui.wong@gmail.com if any question
@author: awang
"""
URL_PinterestBoard=input("Please enter your Pinterest board url starting with Http:// ")

from tkinter import filedialog
Folder_saved=filedialog.askdirectory(title="Select a local folder where you want to put all the pinned pictures")

from lxml import html
import requests

page=requests.get(URL_PinterestBoard)
tree=html.fromstring(page.content)

pins=tree.xpath('//div[@class="pinHolder"]//@href')

del page, tree

import requests, bs4
import urllib

n=1
for singlePin in pins:
  page=requests.get('http://www.pinterest.com'+singlePin)
  page_soup=bs4.BeautifulSoup(page.text,"lxml")
  page_element=page_soup.select('img[src]')
  image_address=page_element[0].attrs['src']
  
  resource=urllib.request.urlopen(image_address)
  output=open(Folder_saved+"/"+"Image"+str(n)+".jpg","wb")
  output.write(resource.read())
  output.close()
  
  n=n+1

This small code can help you download all the pinned pictures in your Pinterest board automatically to a local folder