php curl网络爬虫简单实例代码

<?php
//进行参数传递接收(get请求方式)
//$debug = (isset($argv[1])&&$argv[1]=='debug')?true:false;
$http = "http://www.baidu.com?&id_no=71a6200aba5c2a83455f10d2d00315be";
$wenshu_json = file_get_contents($http);
$wenshu = json_decode($wenshu_json,true);
$wenshu = $wenshu[0];
$case_num = $wenshu['case_num'];
$id_no = $wenshu['id_no'];
$doc_id = $wenshu['doc_id' ];
$case_type = $wenshu['case_type'];
$anyou_code = $wenshu['anyou_code'];
$anyou_name = $wenshu['anyou_name'];
$fayuan_name = $wenshu['fayuan_name'];
$origin_content = $wenshu['origin_content'];
$fayuan_renwei = $wenshu['fayuan_renwei'];
$doc_type = $wenshu['doc_type'];
$judge_level = $wenshu['judge_level'];

(post请求方式)
$data=array(
    'case_type' =>  "民事",
    'judge_level' => $judge_level,
    'doc_type' => "判决",
    'content' =>$origin_content
);
$url = "http://localhost:3000/looklaw";
$ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$ret = curl_exec($ch);
$html = json_decode($ret, true);
var_dump($html);exit;
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值