This article mainly introduces PHP based on Snoopy parsing Web page HTML method, example analysis of the use of Snoopy class parsing HTML files related techniques, with a certain reference value, the need for friends can refer to the following
This article describes the PHP method based on Snoopy parsing Web page HTML, the implementation method is as follows:
Set_time_limit (0); $user = Array (' 20517 ', ' 20518 '); header ("content-type:text/html; Charset=utf-8 "); require_once './snoopy.php '; $snoopy = new Snoopy ();//$uri = ' http://www.juzimi.com/meitumeiju '; $uri = ' http://www.juzimi.com/meitumeiju?page=1 '; $snoopy->fetch ($uri); $con = $snoopy->getresults (); $doc = new DOMDocument (); $doc->loadhtml ($con);/* Make a result array ... */$result = [];/* go through all nodes which has class= " Baby "... * * $i = 0;foreach ((new Domxpath ($doc))->query ('//*[@id =" Bdshare "] ') as $element) {$row = $doc->sa Vehtml ($element); $start = Stripos ($row, ' {'); $end = Stripos ($row, '} '); $len = $end-$start + 1; $json = substr ($row, $start, $len); $json = Str_replace ("'", ' "', $json); $obj = Json_decode ($json); $pic = $obj->pic; $desc = $obj->desc; $filename = '/uploads/meiju/card '. Date (' Ymdhis '). $i. '. png '; $file = '/alidata/www/test '. $filename; $image = file_get_contents ($pic); File_put_contents ($file, $image);}
Summary: the above is the entire content of this article, I hope to be able to help you learn.
Related recommendations:
Php+mysql+jquery statistics current number of users online
Php+mysql+jquery implementation of Query and list box selection
PHP implementation of digital format, the number of every three comma-plus function function