Created
October 4, 2018 20:24
-
-
Save Nutscracker87/dac6693e7f1c88f07da02d4ab4147660 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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