抓取http://www.coolgames.com/的游戏图片和路径信息
<?php
header('Content-Type: text/html; charset=utf-8');
//$content = file_get_contents("http://www.coolgames.com/");// 1. 初始化
$ch = curl_init();
// 2. 设置选项,包括URL
curl_setopt($ch, CURLOPT_URL, "http://www.coolgames.com/");//设置需要抓取数据的网址
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果保存到字符串中还是输出到屏幕上
curl_setopt($ch, CURLOPT_HEADER, 0);//把一个头包含在输出中,设置这个选项为一个非零值。
// 3. 执行并获取HTML文档内容
$html = curl_exec($ch);
// 4. 释放curl句柄
curl_close($ch);
$listNumberStr = "#<div class=\"pod\"><a href=\"([^\"]+)\" class=\"thumb\"><img src=\"([^\"]+)\" alt=\"([^\"]+)\"#isU"; //正则匹配
if(preg_match_all($listNumberStr, $html ,$match)) {
var_dump($match);
} else {
echo "不匹配.";
}