您的位置:首页 > 其它

CURL 抓取网页内容,模拟post

2014-10-24 10:27 162 查看
<?php

//$fh=file_get_contents("http://191.168.1.102/ecshop/ecmobile/index.php?url=/goods");

//print_r($fh);

header('Content-Type:text/html;charset=utf-8'); //避免输出乱码

// 创建一个新cURL资源

$ch = curl_init();

// 设置URL和相应的选项

curl_setopt($ch, CURLOPT_URL, "http://191.168.1.102/ecshop/ecmobile/index.php?url=/tinyCategory");

curl_setopt($ch, CURLOPT_HEADER, 0);

//打开 post ,进行传递参数

curl_setopt( $ch, CURLOPT_POST, true );

//curl_setopt( $ch, CURLOPT_POSTFIELDS, "&goods_id=".$value."¶ms=".$value2 );

// curl_setopt( $ch, CURLOPT_POSTFIELDS, "&goods_id=1");

curl_setopt( $ch, CURLOPT_POSTFIELDS, "&price_min=1&price_max=1000");

// 抓取URL并把它传递给浏览器

$contents = curl_exec($ch);

print_r($contents);

// 关闭cURL资源,并且释放系统资源

curl_close($ch);

?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: