来自: http://www.oschina.net/code/snippet_205431_11454

header
('Content-type:text/html;charset=utf-8'); //抓取河南省高考成绩 require './simple_html_dom.php'; //require './Snoopy.class.php'; $ch = curl_init(); $url = 'http://www.heao.gov.cn/PZQuery/PZCJQuery.aspx'; //数据 $arr = array( 'KSH'=>'12345678901234', 'BMXH'=>'123456789012', 'SFZH'=>'420107199007071510', ); $headers = array( 'User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36', 'Referer:http://www.haedu.gov.cn/hadoe_plus/gk_cx/query_iframe.aspx', ); /* $snoopy = new Snoopy ; $snoopy->agent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"; $snoopy->referer = "http://www.haedu.gov.cn/hadoe_plus/gk_cx/query_iframe.aspx" ; $action = "http://www.heao.gov.cn/PZQuery/PZCJQuery.aspx"; $snoopy->submit($action,$arr); $dom = str_get_html( $snoopy->results ) ; echo $dom; */ curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER,$headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arr)); $data = curl_exec($ch); curl_close($ch); $dom = str_get_html( $data ); $a = $dom->find( 'div.result span#ErrorMSG' ); if(count( $a ) == 1){ echo $a[0]->text(); }

 

posted on 2014-02-11 15:51  睡着的糖葫芦  阅读(2459)  评论(0编辑  收藏  举报