Skip to content

Instantly share code, notes, and snippets.

@francolaiuppa
Created July 1, 2014 13:53
Show Gist options
  • Save francolaiuppa/d97096bf7be37a3455ee to your computer and use it in GitHub Desktop.
Save francolaiuppa/d97096bf7be37a3455ee to your computer and use it in GitHub Desktop.
Droplr Scrapper
<?php
function droplr($droplrUrl = 'http://d.pr/i/YBbX') {
$data = file_get_contents($droplrUrl);
$result = array();
$dom = new DOMDocument;
$dom->loadHTML($data);
foreach ($dom->getElementsByTagName('img') as $node) {
$result[] = $dom->saveHtml($node);
}
$scrapedImage = array_pop($result);
$scrapedImage = explode('src="',$scrapedImage);
$scrapedImage = str_replace('">', '', $scrapedImage[1]);
die($scrapedImage);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment