Freelance Web Developer

Say Hi

Sep 2, 2012

Get the Image link of a Tumblr post

I was trying trying IFTTT and wanted to save my Tumblr liked image post to Dropbox. Searched Google for it but found nothing I can get direct image link with post url. So I decided to scrape post html to get link.

TIP: When you have to scrape and web page think about its mobile version, they are always light weighted and with simple dom structures.

Tumblr provides a mobile version for their blogs, you can open this my simply putting /mobile at  the end of home page url. So its its, mobile version ll be at

Here is simple PHP function that returns the image permalink by post url.

$url = explode("/", $_GET['u']);
$data = file_get_contents("http://".$url[2]."/mobile/post/".$url[4]);
preg_match_all('<a href="(.*?)">',$data,$matches,PREG_PATTERN_ORDER);
//check if high res big image available

Hope this ll help you.

Labels: , , ,

By :