2
我目前正在尝试编写一个脚本,该脚本将使用cURL连接到站点。使用cURL登录站点
我lookod为做到这一点的方式,并试图饼干,但我不知道什么饼干是登录cookie ......如果有人能帮助感谢...
但我试过另一种方式。 ..使用CURLOPT_POSTFIELDS但比我发现该网站使用的登录表单上得到我想这(什么?!)所以:
$username="User";
$password="Pass";
$url="http://www.site.com/register/?action=login&user=".$username."&password=".$password;
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($ch);
echo $result;
curl_close($ch);
但它没有工作......有什么办法以不同方式登录网站?该网站有“方法= GET”,但它并不真正使用...
<form method="get" action="/register/" name="connectform">
<input type="hidden" name="action" value="login"/><input type="hidden" name="returnpage" value=""/>
<ul class="login_form">
<li><label>login :</label> <input type="text" name="login_login" maxlength="24" value="" class="input2"/><span class="error"></span></li>
<li><label>Password :</label> <input type="password" name="login_password" maxlength="24" value="" class="input2"/><span class="error"></span></li>
</ul>
<div class="login_button" style="display:inline-block">
<a class="small_button" onclick="javascript:document.connectform.submit()"><span>Connect to my account</span></a>
<input type="submit" style="display:none" />
</div>
</div>
</form>
我该怎么办? 我不在乎这些方式,你会帮助我,但我更喜欢饼干的方式...... 非常感谢!
是的,我之前做过,当我在这里写下时,我只是编辑了名字。 –
你能告诉我们你要登录哪个页面吗?我想观看网络活动,以便我可以帮助你。或者直接使用最受欢迎的浏览器中包含的开发人员工具(如Google Chrome;按F12,然后转到网络并登录到该页面)。 – DragonWork
谢谢DragonWork!我查看了网络部分,并找到了解决方案!我忘了其中一个领域。 –