How to Scrape Pinterest in 2025

Learn how to extract dynamic Pinterest data using Python, headless browsers, and automated scraper APIs for fast, scalable results.
9 min read
How to Scrape Pinterest blog image

Extracting data from Pinterest is different from most HTML scraping jobs. Pinterest generates all of its content dynamically and doesn’t leave any of its data structures, like JSON, on the page.

If you decide to follow along, you’ll learn how to collect Pinterest data using the following methods:

What Can You Extract?

If you look at Pinterest in your browser, all of the pins are deeply nested inside a div element with data-test-id="pinWrapper".

Inspect Pin

If we can find all of these objects on the page, we can extract all of their data, such as:

  • The title of each pin.
  • The url pointing directly to the pin.
  • The image of the pin from the search results.

Scraping Pinterest With Playwright

Getting Started

There are a lot of great scraping libraries in Python, and we’ll be using Playwright. First, you need to make sure you have Playwright installed. You can view their docs here. Playwright is one of the best headless browsers available.

Install Playwright

pip install playwright

Install Playwright’s Browsers

playwright install

Scraping the Actual Pins

Now, let’s look at how to scrape the actual pins from Pinterest. In the code below, we create two functions, scrape_pins() and main()scrape_pins() opens a browser and extracts data from Pinterest. main() gets used as an entry point for the async runtime.

import asyncio
from playwright.async_api import async_playwright
import json

user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36"


async def scrape_pins(query):
    search_url = f"https://www.pinterest.com/search/pins/?q={query}&rs=typed"
    scraped_data = []

    async with async_playwright() as p:
        browser = await p.chromium.launch()
        page = await browser.new_page(user_agent=user_agent)
        response = await page.goto(search_url)
        await asyncio.sleep(2)
        try:
            #find the pins on the page
            pins = await page.query_selector_all("div[data-test-id='pinWrapper']")

            #iterate through the pins and extract data
            for pin in pins:
                title_link = await pin.query_selector("a")
                pin_url = await title_link.get_attribute("href")
                title = await title_link.get_attribute("aria-label")
                img = await title_link.query_selector("img")
                img_src = await img.get_attribute("src")

                extracted_data = {
                    "title": title,
                    "url": pin_url,
                    "img": img_src
                }
                #add the data to our results
                scraped_data.append(extracted_data)
        except:
            print(f"Failed to scrape pins at {search_url}")
        finally:
            await browser.close()
    #everything has finished, return our scraped data
    return scraped_data

async def main():
    search_query = "office"
    office_results = await scrape_pins(search_query)

    with open(f"{search_query}-results.json", "w") as file:
        try:
            json.dump(office_results, file, indent=4)
        except Exception as e:
            print(f"Failed to save results: {e}")

if __name__ == "__main__":
    asyncio.run(main())

scrape_pins() performs the following steps during our scrape:

  • Create our url: search_url.
  • Create an array to hold our results, scraped_data.
  • Open a new browser instance.
  • Set a custom user_agent in order to run in headless mode. Without it, Pinterest will block us.
  • We wait two seconds for content to load with asyncio.sleep(2).
  • We find all of the visible pins on the page using this selector: div[data-test-id='pinWrapper'].
  • For each pin, we extract the following data:
    • title: The title of the pin.
    • url: The url leading directly to the pin.
    • img: The image of the pin displayed in the search results.

Here is some sample data from the Playwright scraper above.

[
    {
        "title": "A minimalist office featuring a soothing color palette of whites, greys, and natural wood accents, creating a calm and spacious feel3",
        "url": "/pin/10203536650743650/",
        "img": "https://i.pinimg.com/236x/b3/21/e2/b321e2485da40c0dde2685c3a4fdcb56.jpg"
    },
    {
        "title": "a home office with two desks and an open door that leads to the outside",
        "url": "/pin/261912534574291013/",
        "img": "https://i.pinimg.com/236x/56/f1/29/56f129512885e1b3c9971b16f9445c9a.jpg"
    },
    {
        "title": "home office decor, blakc home office, dark home office, moody home office, small home office",
        "url": "/pin/60094976273327121/",
        "img": "https://i.pinimg.com/236x/ba/75/c9/ba75c9be7e635cce3ee80acdf70d6f9f.jpg"
    },
    {
        "title": "an office with a desk, chair and bookshelf in the middle of it",
        "url": "/pin/599682506666665720/",
        "img": "https://i.pinimg.com/236x/57/66/1d/57661dc80bebda3dfe946c070ee8ed13.jpg"
    },
    {
        "title": "a home office with green walls and plants on the shelves, along with a computer desk",
        "url": "/pin/1147080967585091410/",
        "img": "https://i.pinimg.com/236x/ce/e8/b7/cee8b74151b29605a80e0f61898c249d.jpg"
    },

Scraping Pinterest With the Bright Data Scraper API

With our Pinterest Scraper API, you can completely automate this process and you don’t have to worry about headless browsers, selectors, or anything else!

Bright Data Pinterest Scraper

Make sure you’ve got Python Requests installed.

Install Requests

pip install requests

After you’ve set up your API call, you can trigger it from Python. Below, we also have two functions: get_pins() and poll_and_retrieve_snapshot().

  • get_pins(): This function takes a keyword alongside your api_key. It then creates and sends a request to our scraper API. This request triggers a scrape of Pinterest for your desired keyword.
  • poll_and_retrieve_snapshot() takes your api_key and the snapshot_id. It then checks every 10 seconds to see if the snapshot is ready. Once the snapshot is ready, the data is downloaded and we exit the function.
import requests
import json
import time

#function to trigger the scrape
def get_pins(api_key, keyword):
    url = "https://api.brightdata.com/datasets/v3/trigger"
    headers = {
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json",
    }
    params = {
        "dataset_id": "gd_lk0sjs4d21kdr7cnlv",
        "include_errors": "true",
        "type": "discover_new",
        "discover_by": "keyword",
    }
    data = [
        {"keyword":keyword},
    ]
    #trigger the scrape
    response = requests.post(url, headers=headers, params=params, json=data)
    #return the snapshot_id
    return response.json()["snapshot_id"]

def poll_and_retrieve_snapshot(api_key, snapshot_id, output_file="snapshot-data.json"):
    #create the snapshot url
    snapshot_url = f"https://api.brightdata.com/datasets/v3/snapshot/{snapshot_id}?format=json"
    headers = {
        "Authorization": f"Bearer {api_key}"
    }

    print(f"Polling snapshot for ID: {snapshot_id}...")

    while True:
        response = requests.get(snapshot_url, headers=headers)

        if response.status_code == 200:
            print("Snapshot is ready. Downloading...")
            snapshot_data = response.json()
            #write the snapshot to a new json file
            with open(output_file, "w", encoding="utf-8") as file:
                json.dump(snapshot_data, file, indent=4)
            print(f"Snapshot saved to {output_file}")
            break
        elif response.status_code == 202:
            print("Snapshot is not ready yet. Retrying in 10 seconds...")
        else:
            print(f"Error: {response.status_code}")
            print(response.text)
            break

        time.sleep(10)


if __name__ == "__main__":

    API_KEY = "YOUR-BRIGHT-DATA-API-KEY"
    KEYWORD = "office"

    snapshot_id = get_pins(API_KEY, KEYWORD)
    poll_and_retrieve_snapshot(API_KEY, snapshot_id)

Here is some sample data from the downloaded file. Since our trigger request had "include_errors": "true", the file also included pins with errors. The sample data below includes two error pins as well as two pins with good data.

[
    {
        "post_type": null,
        "timestamp": "2025-02-17T15:26:17.248Z",
        "input": {
            "url": "https://www.pinterest.com/pin/jh46IGe2",
            "discovery_input": {
                "keyword": "office"
            }
        },
        "warning": "Bad input. Wrong id!",
        "warning_code": "dead_page",
        "discovery_input": {
            "keyword": "office"
        }
    },
    {
        "post_type": null,
        "timestamp": "2025-02-17T15:26:18.757Z",
        "input": {
            "url": "https://www.pinterest.com/pin/4471026676503806548",
            "discovery_input": {
                "keyword": "office"
            }
        },
        "warning": "Bad input. Page does not exist.",
        "warning_code": "dead_page",
        "discovery_input": {
            "keyword": "office"
        }
    },
    {
        "url": "https://www.pinterest.com/pin/929782285570058239",
        "post_id": "929782285570058239",
        "title": "Essential Tips for Designing a Functional Small Office Space: Maximize Efficiency",
        "content": "17 Smart Tips for Designing a Productive Small Office Space",
        "date_posted": "2025-02-06T15:00:47.000Z",
        "user_name": "wellnesswink",
        "user_url": "https://www.pinterest.com/wellnesswink",
        "user_id": "929782422978147260",
        "followers": 232,
        "likes": 0,
        "categories": [
            "Explore",
            "Home Decor"
        ],
        "attached_files": [
            "https://i.pinimg.com/originals/c8/c0/d5/c8c0d5fb45352e40535db4510049a142.jpg"
        ],
        "image_video_url": "https://i.pinimg.com/originals/c8/c0/d5/c8c0d5fb45352e40535db4510049a142.jpg",
        "video_length": 0,
        "post_type": "image",
        "comments_num": 0,
        "discovery_input": {
            "keyword": "office"
        },
        "timestamp": "2025-02-17T15:26:19.502Z",
        "input": {
            "url": "https://www.pinterest.com/pin/929782285570058239",
            "discovery_input": {
                "keyword": "office"
            }
        }
    },
    {
        "url": "https://www.pinterest.com/pin/889812838892568569",
        "post_id": "889812838892568569",
        "title": "20 Modern Masculine Home Office Design Ideas for Men",
        "content": "Explore 25 chic home office decor ideas that blend style and functionality. Create a workspace you love and boost your productivity effortlessly!",
        "date_posted": "2025-01-27T07:11:38.000Z",
        "user_name": "artfullhouses",
        "user_url": "https://www.pinterest.com/artfullhouses",
        "user_id": "889812976285233957",
        "followers": 10,
        "likes": 0,
        "categories": [
            "Explore",
            "Home Decor"
        ],
        "attached_files": [
            "https://i.pinimg.com/originals/f1/cb/f7/f1cbf7b127db2bef2306ba19ffcc0646.png"
        ],
        "image_video_url": "https://i.pinimg.com/originals/f1/cb/f7/f1cbf7b127db2bef2306ba19ffcc0646.png",
        "video_length": 0,
        "hashtags": [
            "Mens Desk Decor",
            "Chic Home Office Decor",
            "Mens Desk",
            "Home Office Ideas For Men",
            "Office Ideas For Men",
            "Masculine Home Office Ideas",
            "Masculine Home Office",
            "Masculine Home",
            "Chic Home Office"
        ],
        "post_type": "image",
        "comments_num": 0,
        "discovery_input": {
            "keyword": "office"
        },
        "timestamp": "2025-02-17T15:26:20.069Z",
        "input": {
            "url": "https://www.pinterest.com/pin/889812838892568569",
            "discovery_input": {
                "keyword": "office"
            }
        }
    },

As you can see, the Scraper API collects far more data than the initial scraper we built with Playwright. Our API crawls Pinterest for your keyword and then scrapes all the individual pins that it finds during the crawl.

Convenience is not our only benefit from this approach. Our Pinterest Scraper API extracts your data at an extremely low cost. Our total results file was almost 45,000 lines long and it only cost $0.97 to generate.

Pinterest Scrape Cost

Hiring someone to build a scraper of the same quality would likely cost several hundred dollars and you’d have to wait days for your data. With our Scraper API, you get your data within minutes at just a fraction of the cost.

Conclusion

Extracting data from Pinterest doesn’t have to be difficult. Whether you build your own scraper using Playwright or opt for a fully automated solution like our Pinterest Scraper, the right approach depends on your needs.

For quick, reliable, and scalable Pinterest data extraction, Bright Data’s Scraper API eliminates the hassle of handling headless browsers, proxies, and CAPTCHAs —delivering structured data effortlessly.

Faster results – Get data in minutes, not hours
Cost-efficient – Pay only for what you extract
No maintenance – Avoid dealing with blocked requests

Start your free trial today and streamline your Pinterest scraping with Bright Data’s Web Scraper API!

No credit card required