关于模拟post提交获取数据
程序员文章站
2022-06-11 19:44:55
...
给位大侠,帮忙看一下代码,怎么就不能得到我想要的数据?麻烦给予指点,谢谢。
$data = "bkxhtxt=15370282131039&sfzhtxt=%C0%EE%C3%F7%D6%E9&Button1=%B2%E9+%D1%AF";
$url = "http://lqcx.sdyu.edu.cn/2015yk/getScore.asp";
$headers = array(
"User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 SE 2.X MetaSr 1.0",
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Language: zh-CN,zh;q=0.8",
"Referer: http://lqcx.sdyu.edu.cn/2015yk/"
);
//ob_start();
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch,CURLOPT_REFERER,"http://lqcx.sdyu.edu.cn/2015yk/");
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($curl);
//$retrievedhtml = ob_get_contents();
//ob_end_clean();
curl_close($curl);
$result = iconv("GBK", "UTF-8//IGNORE", $output);
$score = explode(",",$result);
$content = "考生号:".$Number."\n"."姓名:".$Name."\n"."专业:".$score."\n"."成绩:".$Score[3]."\n"."科类名次:".$score[4];
return $content;
$data = "bkxhtxt=15370282131039&sfzhtxt=%C0%EE%C3%F7%D6%E9&Button1=%B2%E9+%D1%AF";
$url = "http://lqcx.sdyu.edu.cn/2015yk/getScore.asp";
$headers = array(
"User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 SE 2.X MetaSr 1.0",
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Language: zh-CN,zh;q=0.8",
"Referer: http://lqcx.sdyu.edu.cn/2015yk/"
);
//ob_start();
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch,CURLOPT_REFERER,"http://lqcx.sdyu.edu.cn/2015yk/");
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($curl);
//$retrievedhtml = ob_get_contents();
//ob_end_clean();
curl_close($curl);
$result = iconv("GBK", "UTF-8//IGNORE", $output);
$score = explode(",",$result);
$content = "考生号:".$Number."\n"."姓名:".$Name."\n"."专业:".$score."\n"."成绩:".$Score[3]."\n"."科类名次:".$score[4];
return $content;
回复讨论(解决方案)
(.*)/', $result, $match);$content = "考生号:".$match[1][0]."\n"."姓名:".$match[1][1]."\n"."专业:".$match[1][2]."\n"."成绩:".$match[1][3]."\n"."科类名次:".$match[1][4]."\n";print_r($content);考生号:15370282131039姓名:李明珠专业:播音与主持艺术成绩:164.26 科类名次:13怎么给不了分啊?
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
相关文章
相关视频
推荐阅读
-
jquery获取checkbox的值并post提交
-
关于iframe跨域POST提交的方法示例
-
解决Vue axios post请求,后台获取不到数据的问题方法
-
vue.js配合$.post从后台获取数据简单demo分享
-
php获取post中的json数据的实现方法
-
微信小程序授权 获取用户的openid和session_key【后端使用java语言编写】,我写的是get方式,目的是测试能否获取到微信服务器中的数据,后期我会写上post请求方式。
-
四种常见的 POST 提交数据方式对应的content-type
-
php 模拟POST提交的2种方法详解
-
python使用post提交数据到远程url的方法
-
以$.post方式提交数据并以json格式返回数据(代码教程)