Skip to content

Instantly share code, notes, and snippets.

@Nutscracker87
Created October 4, 2018 20:24
Show Gist options
  • Select an option

  • Save Nutscracker87/dac6693e7f1c88f07da02d4ab4147660 to your computer and use it in GitHub Desktop.

Select an option

Save Nutscracker87/dac6693e7f1c88f07da02d4ab4147660 to your computer and use it in GitHub Desktop.
require_once 'phpQuery/phpQuery.php';
$str = file_get_contents('source_url');
$pq = phpQuery::newDocument($str);
$links = $pq->find('.body a > img'); //like jquery tags
foreach ($links as $link) {
$pqLink = pq($link); //pq make phpQuery object
$src[] = $pqLink->attr('src');
}
for($i=0;$i<count($src);$i++){
$tmp = $src[$i]; //get file name
$tmp = 'img/'.$tmp;
file_put_contents($tmp,file_get_contents($src[$i]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment