我一直在尋找一些東西,可以幫助我與此。如何在提交回前自動生成隱藏的輸入
這是我想要的捲曲度
<form action="http://www.website.com/login?from=login" class="lightbox_form" method="post" name="login">
<input name="authenticity" type="hidden" value="da1249c71258cd02a8bd038cf3ccca1c9ebef155" />
<input type="text" name="login_or_email" size="20" class="input" id="login">
<input type="password" size="20" name="login_password" class="input" id="word_user">
<button type="submit" class="new_submit"><span class="inner">Log In</span></button>
</form>
模擬登錄如果看到你看到下面
<input name="authenticity" type="hidden" value="da1249c71258cd02a8bd038cf3ccca1c9ebef155" />
即自動生成,改變了每次重裝網站隱藏價值例子的形式。
我正在使用CURL,但我不知道如何獲取隱藏字段並在同一會話中提交回來。嘗試使用get_meta_tags但沒有工作
set_time_limit(0);
$http_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.30729)";
$header = array();
$header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
$header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
$header[] = "Cache-Control: max-age=0";
$header[] = "Connection: keep-alive";
$header[] = "Keep-Alive: 300";
$header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header[] = "Accept-Language: en-us,en;q=0.5";
$header[] = "Pragma: "; // browsers keep this blank.
curl_setopt($ch, CURLOPT_URL, "http://www.website.com/login?from=login");
curl_setopt($ch, CURLOPT_USERAGENT, $http_agent);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_COOKIEJAR, ROOT_DIR.'cookies.txt');
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
//curl_setopt($ch, CURLOPT_POSTFIELDS, 'login_or_email=mail&login_password=pass&authenticity_token='.$cag.'');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
//print $output;
print_r ($output);
任何想法?
耶這就是偉大的,但如果我得到隨機值,捲曲和發回的捲曲度,其將與新的再生.. – radiaku 2012-03-05 17:06:25
我不明白您的評論。您具有$ match [1]中隱藏字段的值,因此您可以在下一個curl請求中使用它。 – botzko 2012-03-06 18:07:56
是的,我已經有$ match [1]了,但是當我再次創建CURL時,它會生成一個新的。所以我必須得到隱藏的價值,並將其送回一個CURL,這是否可行? – radiaku 2012-03-06 19:04:18