当前位置:Gxlcms > PHP教程 > 关于模拟post提交获取数据

关于模拟post提交获取数据

时间:2021-07-01 10:21:17 帮助过:19人阅读

给位大侠,帮忙看一下代码,怎么就不能得到我想要的数据?麻烦给予指点,谢谢。
$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;


回复讨论(解决方案)

(.*)<\/div><\/td>/', $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

怎么给不了分啊?

人气教程排行