Skip to content
Advertisement

pinterest web scrape image

I’m trying to get a url from a pinterest image and send a url of it through the general profile of the user on pinterest, but it’s returning me undefined

enter image description here

my code:

JavaScript

Advertisement

Answer

The problem is that the page is still loading. #mweb-unauth-container > div > div:nth-child(2) doesn’t exist, because #mweb-unauth-container > div only has one div child, and it’s a loading icon. I don’t think this is something you can do with cheerio, you’ll have to use an alternative that can resolve Javascript (such as Puppeteer).

Alternatively, if you don’t want to scrape, you can use a private API (which, although subject to change at any point, would definitely be more performant):

https://widgets.pinterest.com/v3/pidgets/users/n1cotin3/pins/

Example:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement