About simulating post submission to obtain data-php Tutorial

Source: Internet
Author: User
For information on simulating post submission to obtain data, let's take a look at the code. Why can't I get the data I want? Please give me some advice. thank you.
$ 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 = "student ID :". $ Number. "\ n ". "name :". $ Name. "\ n ". "Major :". $ score. "\ n ". "Score :". $ Score [3]. "\ n ". "category ranking :". $ score [4];
Return $ content;


Reply to discussion (solution)

 

(. *) <\/P> <\/td>/', $ result, $ match); $ content = "student ID :". $ match [1] [0]. "\ n ". "name :". $ match [1] [1]. "\ n ". "Major :". $ match [1] [2]. "\ n ". "Score :". $ match [1] [3]. "\ n ". "category ranking :". $ match [1] [4]. "\ n"; print_r ($ content );



Student No.: 15370282131039 name: Li Mingzhu major: Broadcasting and host artistic achievement: 164.26 subject ranking: 13

Why can't I score?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.