Php uses preg_match_all to match the image in the article
- $ Con = file_get_contents ("http://bbs.it-home.org/news/jbxue-1.html ");
- $ Pattern = "/<[img | IMG]. *? Src = [\ '| \ "] (. *? (? : [\. Gif | \. jpg | \. png]) [\ '| \ "]. *? [\/]?> /";
- Preg_match_all ($ pattern, $ con, $ match );
- Print_r ($ match );
- ?>
-
Result: Array ([0] => Array ([0] => [1] => [2] =>) [1] => Array ([0] => http://bbs.it-home.org/usr/themes/dddefault/images/logo.png [1] => http://bbs.it-home.org/usr/uploads/2012/09/531656480.jpg [2] => http://bbs.it-home.org/usr/uploads/2012/09/2647136297.jpg )) Articles you may be interested in: php code for matching image addresses: a PHP regular expression matching date and time (timestamp conversion) example php matches the regular expression of any Web site php regular expression rewrite html image img path code example PHP regular expression get URL domain name code use preg_replace function match image and add link method php the regular expression matches the domain name in the URL. |