我一直在寻找一些东西,可以帮助我与此。如何在提交回前自动生成隐藏的输入
这是我想要的卷曲度
<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