复制代码 代码如下:
$curlpost = 'a=1&b=2';//模拟post数据
$ch = curl_init();
curl_setopt($ch, curlopt_httpheader, array('x-forwarded-for:0.0.0.0', 'client-ip:0.0.0.0')); //构造ip
curl_setopt($ch, curlopt_referer, "http://www.jb51.net/"); //构造来路
curl_setopt($ch,curlopt_url, 'http://www.jb51.net');//需要抓取的页面路径
curl_setopt ($ch, curlopt_returntransfer, 1);
curl_setopt ($ch, curlopt_timeout, 30);
curl_setopt($ch, curlopt_postfields, $curlpost);//post值
$file_contents = curl_exec($ch);//抓取的内容放在变量中
curl_close($ch)
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!