在某人说出某些内容之前,或者"跳跃,"我想说我读过:
这是我的功能:
function UolgetHtmlfromAjaxCallback($a_Params,$url) {
$EVENTTARGET = $this->UolgetAtributoEventTarget($a_Params['s_EventTarget']);
$s_smMaster = 'ctl00$cphSite$upModelo|'.$entries['target'];
$VIEWSTATE = urlencode($a_Params['s_ViewState']);
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "spider", // who am i
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
CURLOPT_TIMEOUT => 120, // timeout on response
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => 'ct100%24smMaster='.urldecode($s_smMaster).
'&__EVENTTARGET='.urlencode($EVENTTARGET['target']).
'&__EVENTARGUMENT='.urlencode('').
'&__EVENTVALIDATION='.urlencode($s_Eventvalidation).
'&__VIEWSTATE='.$VIEWSTATE.
'&ct100%24txtBuscaNome='.$a_Params['ctl00_txtBuscaNome'].
'&__ASYNCPOST=true'
);
$ch = curl_init( $url );
curl_setopt_array( $ch, $options );
$result = curl_exec ($ch);
return $result;
}
$VIEWSTATE
没问题,$EVENTTARGET
是一个包含这些值的数组:
Array (
[id] => ctl00_cphSite_fichaTecnicaEditorial_rptCarrosFichaTecnica_ctl00_lbtnFichaTecnica
[target] => ctl00$cphSite$fichaTecnicaEditorial$rptCarrosFichaTecnica$ctl00$lbtnFichaTecnica )
我试图使用此代码来抓取这个网站:
http://comparecar.uol.com.br/Modelo/Volvo-Xc60
我得到了网站,但没有收到汽车的信息。
我编辑自己的信息。
我正在使用Tamper Data,我发现帖子使用了不同的参数:
ctl00%24smMaster
__EVENTTARGET
__EVENTARGUMENT
__VIEWSTATE
__EVENTVALIDATION
ctl00%24txtBuscaNome
__ASYNCPOST
以" ="
结束