Web Development

Scraping Pinterest with PHP


I finally started updating this site again. Nice new graphics, fresh typography (via Google Web Fonts). I even took the time to code a parser for Pinterest’s JSON files, so that I could include my Pinboards here (fresh content for this site that I don’t have to code, equals a plus in my book).

So I do all of that and what happens just a week after going live? The JSON files are killed off…just my luck.

To remedy the situation, I’ve written a swanky new php class for scraping said data from my Pinterest page. It’s not very extensive, but it serves my purposes and helped introduce me to the PHP Simple HTML DOM Parser. If you’d like to use it, feel free to download it below. I’d love to hear about it in the comment section if you do you use it.

NOTE: Not that I get a huge amount of traffic, but it's probably best not to scrape their site every time mine (or yours) reloads, right? That said, the class is designed to only scrape data from Pinterest once an hour. If your testing, just bypass the section within loadHTML().

Download Pinterest scraper

Web Development
Code Perfection
General News
Best Web Developer Tools Updated
Web Development
Simple Pagination in Laravel
  • Alejandro

    AlejandroAlejandro

    Author Reply

    does this class get all images in a board? I have hundreds!

    Thanks!


  • Tom

    TomTom

    Author Reply

    MAN! This is great. REALLY excellent. It generates the html and works. However… in the generated xxxxxPinterest.html page…. one double click brings it up, except the boards and images are not visible. the followers are there… the title… the graphics…. the css… background…. but I don’t see any content below the lower page devider. For example I used echo “”; print_r($pinterestCovers); echo “”; to get a pretty print out of the array and data is all there! That’s plenty good enough!) …. but just wondering if I missed something. Great job. I would really appreciate a word back. Otherwise, I can take the array a populate my own board(s) with the data and images. A thousand thanks!


  • Casper Overgaard

    I’ve really been searching for a way to fetch my pinterest pins and display them on my website. Finally found something that didn’t rely on pinterest’s rss feed!

    My problem is that I’m not very hardcore in php. I’ve implemented the script as it should. My problem is when I have to parse the information in the arrays into something nice.

    I tried print_r($pinterestCovers); but that only spits out the array with image url links. How do I convert this into some lovely images?


Leave a Reply to Alejandro Cancel reply