关于模拟post提交获取数据

WBOY
Release: 2016-06-23 13:35:38
Original
769 people have browsed it

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


回复讨论(解决方案)

<?php$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);preg_match_all('/<td><div align="center">(.*)<\/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);
Copy after login


考生号:15370282131039姓名:李明珠专业:播音与主持艺术成绩:164.26 科类名次:13
Copy after login

怎么给不了分啊?

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!