π Pinterscrape is a simple and lightweight web scraper for pinterest.
Important
Pinterscrape currently only supports image scraping. Attempting to scrape videos or stories will result in an error.
// https://pinterest.com/pin/<PIN-ID>
const pin = await pinterscrape.get("682084306094066099")
{
author: "digitalsynopsis",
caption: "#design #GraphicDesign #LogoDesign #WebDesign #clients #fonts #Photoshop #advertising #AgencyLife #artist #designer #developer #GraphicDesigner #LogoDesigner #WebDesigner #memes #agency #ArtDirector #CreativeDirector #AdAgency",
image: "https://i.pinimg.com/originals/4f/90/19/4f9019df1b5bddb1a6c973ccbfb16693.jpg",
pin: "682084306094066099"
}
Pinterscrape offers online usage at /demo/pinterscrape
Simply call the method get
with the pin ID as a string.
await pinterscrape.get(PIN_ID)
Warning
The argument PIN_ID
must be a string.
This method will return an object. If it does not, it will attempt to scrape it again as a fallback.
{
author: String, // the username of the author
caption: String, // the description written on the pin, null if no caption
image: String, // the URL of the original pin image
pin: String // the pin ID; use this to verify if the scraping is correct
}
Simply call the method search
with the query as a string.
await pinterscrape.search(QUERY)
Note
Pinterest does not accept limitations or pagination for searching during scraping. Therefore, you cannot control the number of pins generated or paginate through them.
This method will return an array of pin IDs.
Most web scrapers use rotating proxies. The default proxy used is creprox.
To use your own proxy, modify the method pinterscrape.proxy
.
pinterscrape.proxy = url => {
return "https://your-proxy.net/?url=" + url
}
When pinterscrape.get
failed to scrape, it will throw an error (at the last attempt) and return the error information (at the first attempt).
{
error: Error,
cause: String
}
If there's an error related to regular expression, cause
could be either image, author, caption, or pin, depending on the part that triggers the error.
Warning
Pinterscrape's usual latency is between 2-4 seconds due to pinterest's source code.