Curl simulates submitting post data
/* $url @ Submit Address $postdata Example $postdata = Array (' key ' = ' value '), */function curlpost ($url, $postData =array ()) {if (Empty ($ URL)) return false; $o = ""; foreach ($postData as $k = = $v) {$o. = "$k =". UrlEncode ($v). " & ";} $postData =substr ($o, 0,-1); $ch = Curl_init (); $timeout = 5; curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, Curlopt_connecttimeout, $timeout); curl_setopt ($ch, Curlopt_post, 1); curl_setopt ($ch, Curlopt_header, 0); curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, Curlopt_postfields, $postData); $contents = Curl_exec ($ch); return $contents;}
CURL Crawl Page
/* * $url @ Grab page address */function getcontents ($url) {$ch = Curl_init (); $timeout = 5; curl_setopt ($ch, Curlopt_url, $url); CU Rl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, Curlopt_connecttimeout, $timeout); $contents = curl_exec ($ch); return $contents;}
Regular grabs to tabel content
/* * $table The content crawled over the page */function Get_td_array ($table) {//Remove HTML Tag Properties $table = Preg_replace ("' <table[^>]*? > ' si ', "", $table); $table = Preg_replace ("' <tr[^>]*?> ' si '," ", $table); $table = Preg_replace (" ' <td[^ >]*?> ' Si ', "", $table), $table = Str_replace ("</tr>", "{tr}", $table) $table = Str_replace ("</td>", "{ TD} ", $table);//Remove HTML Tag $table = preg_replace (" ' <[\/\!] *? [^<>]*?> ' si ', ' ", $table);//Remove the whitespace character $table = Preg_replace (" ' ([\ r \ n]) [\s]+ ' "," ", $table); $table = Str_replace (" "," ", $table); $table = Str_replace (" "," "", $table) $table = Explode (' {tr} ', $table); Array_pop ($table); foreach ($table as $key = $tr) {$td = explode (' {TD} ', $TR); Array_pop ($TD); $TD _array[] = $td;} return $TD _array;}
PHP Simulation Grab the page some functions to organize