我正在尝试使用curl登录basecamp并下载附件。
但是当我卷曲时:
curl -F "username=my-user&password=my-pwd" "https://my-domain.basecamphq.com/login"
它没有验证。出局:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 TRANSITIONAL//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<meta name="robots" content="noindex, nofollow" />
<meta name="csrf-param" content="authenticity_token"/>
<meta name="csrf-token" content="H5w/7j9I5s38oQ9NdVgpkp/QCxIZ3YW+qM/+Hj/ERr0="/>
<title>My Domain Name.: Sign in</title>
<script src="https://my-domain.basecamphq.com/rev_28dd107/sprockets.js?651551a0be3439fa32557210a7eea7d7" type="text/javascript"></script>
<link href="https://my-domain.basecamphq.com/rev_28dd107/application.css" media="screen" rel="stylesheet" type="text/css" />
<link href="https://my-domain.basecamphq.com/rev_28dd107/stylesheets/print/application.css" media="print" rel="stylesheet" type="text/css" />
<!--[if IE]><link href="https://my-domain.basecamphq.com/rev_28dd107/stylesheets/ie/base.css" media="screen" rel="stylesheet" type="text/css" /><![endif]-->
<meta name="queenbee-id" content="1152680" />
<meta name="return-to-location" content="" />
<script type="text/javascript">
if (Login.recoverSessionToken()) {
Login.clearPersistedTokens();
window.location = "";
}
</script>
</head>
<body class="login">
<div class="login">
<h1>My Domain Name.</h1>
<div id="login_dialog" class="login_dialog">
<form accept-charset="UTF-8" action="https://launchpad.37signals.com/authenticate" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="authenticity_token" type="hidden" value="H5w/7j9I5s38oQ9NdVgpkp/QCxIZ3YW+qM/+Hj/ERr0=" /></div>
<input id="product" name="product" type="hidden" value="basecamp" />
<input id="subdomain" name="subdomain" type="hidden" value="my-domain" />
<div id="user_name_login">
<h2>Username</h2>
<input autocapitalize="off" autocorrect="off" id="username" name="username" type="text" /><br/>
<h2>Password</h2>
<input id="password" name="password" type="password" /><br/>
<label><input class="auto" id="remember_me" name="remember_me" type="checkbox" value="1" /> Remember me on this computer</label><br />
<input class="button" name="commit" type="submit" value="Sign in" />
<div class="extras">
<ul>
<li><strong>Help:</strong> <a href="/amnesia/forgot_password">I forgot my username or password</a></li>
</ul>
</div>
</div>
</form></div>
<script type="text/javascript">
//<![CDATA[
$("username").focus()
//]]>
</script>
</div>
</body>
</html>
这里出了什么问题?如果有人帮忙的话会很棒!
提前致谢:)
答案 0 :(得分:2)
从输出中可以看出,通过basecamp网站登录需要的不仅仅是用户名和密码。
至少需要
authenticity_token=H5w/7j9I5s38oQ9NdVgpkp/QCxIZ3YW+qM/+Hj/ERr0=
但每次访问该页面时都会有所不同。
您似乎也可能需要包含
product=basecamp
subdomain=mobme
你的目的是什么? 您是否试图筛选网站?
我建议您只需查看开发人员API http://developer.37signals.com/
或者,如果这还不够,请在Ruby或Perl中试用Mechanize
。
这创建了一个简单的脚本化机器人,它可以加载页面并与之交互,因此您不必担心伪造正确的参数。