您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

利用curl抓取远程页面内容的示例代码_PHP教程

2024/3/19 19:09:13发布20次查看
最基本的操作如下
复制代码 代码如下:
$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)
http://www.bkjia.com/phpjc/328109.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/328109.htmltecharticle最基本的操作如下 复制代码 代码如下: $curlpost = 'a=1//模拟post数据 $ch = curl_init(); curl_setopt($ch, curlopt_httpheader, array('x-forwarded-for:0.0.0.0', 'cli...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product