我正在尝试使用scrapy FormRequest对此特定网站进行登录 https://www.ventureradar.com/
DB::table('codes')->where('redeemed', 0)->pluck('code');
蜘蛛代码:
<form method="post" action="./" onsubmit="javascript:return WebForm_OnSubmit();" id="i_d_LoginButtons" class="navbar-form navbar-right col-md-3" role="search">
<div class="aspNetHidden">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="">
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTYzNDk1ODcxOQ8WAh4TVmFsaWRhdGVSZXF1ZXN0TW9kZQIBFgRmD2QWAmYPFgIeB1Zpc2libGVoZAIBDxYCHglpbm5lcmh0bWwF8gI8YSBocmVmPSIvc2VhcmNoLmFzcHg/a2V5d29yZD1TZW5zb3JzIj5TZW5zb3JzPC9hPiwgPGEgaHJlZj0iL3NlYXJjaC5hc3B4P2tleXdvcmQ9JTIyTWFjaGluZSUyMExlYXJuaW5nJTIyIj5NYWNoaW5lIExlYXJuaW5nPC9hPiwgPGEgaHJlZj0iL3NlYXJjaC5hc3B4P2tleXdvcmQ9Y2xlYW50ZWNoIj5DbGVhbnRlY2g8L2E+LCA8YSBocmVmPSIvc2VhcmNoLmFzcHg/a2V5d29yZD1GaW50ZWNoIj5GaW50ZWNoPC9hPiwgPGEgaHJlZj0iL3NlYXJjaC5hc3B4P2tleXdvcmQ9JTIyRGVlcCUyMExlYXJuaW5nJTIyIj5EZWVwIExlYXJuaW5nPC9hPiwgPGEgaHJlZj0iL3NlYXJjaC5hc3B4P2tleXdvcmQ9YmxvY2tjaGFpbiI+QmxvY2tjaGFpbjwvYT4NCg0KZGRO8qTHEo0fg5Agh/inMCl4RxBi3ukJk6XgRRM0qAXg4g==">
</div>
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['i_d_LoginButtons'];
if (!theForm) {
theForm = document.i_d_LoginButtons;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
<script src="/WebResource.axd?d=Kcz-Ew6evJhFZ-dJU3qdR3jBFefH_AHMnATUn3oIl7EdPiEdy0jrUhbRttuv0TbX_SxAYg49ez_iX9zo86QCQr_8QDfMTY78bAmPSfqcrgA1&t=636125696399126630" type="text/javascript"></script>
<script src="/WebResource.axd?d=cgsadF9ZCRBBHsYBNAIK77TCMaXztKWYzNf21djJ9RRxfPVsnWJ7eQSxsgCczLW455eH8XEOZSrJBJpap84Qu_S-wNa9E5Ggmz-3QlizhE81&t=636125696399126630" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function WebForm_OnSubmit() {
if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
return true;
}
//]]>
</script>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="318D363F">
</div>
<input name="i_h_UserID" type="hidden" id="i_h_UserID">
<input name="i_h_SearchKeyword" type="hidden" id="i_h_SearchKeyword">
<div style="" id="i_d_loginregistercontainerparent">
<button id="i_b_Login" type="button" class="btn btn-default" onclick="toggleLogin();">login</button>
<button id="i_b_Register" type="button" class="btn btn-default" onclick="toggleRegister();">free sign-up</button>
</div>
<div id="i_d_logincontainer">
<div id="i_d_login" style="display: none;">
<p>
</p>
<div style="margin-bottom: 10px">
<div id="i_d_Login_Message"></div>
<div>
<input name="UserName" type="text" id="UserName" placeholder="Email address">
<div class="formErrorsContainer">
<span id="RequiredValidatorEmail" style="display:none;">Please enter Email</span><span id="RegExValidatorEmail" style="display:none;">Incorrect Email format</span>
</div>
</div>
</div>
<div style="margin-bottom: 10px">
<div>
<input name="Password" type="password" id="Password" placeholder="Password">
<div class="formErrorsContainer">
<span id="RequiredValidatorPassword" style="display:none;">Please enter Password</span>
</div>
<div class="help-block text-right"><a href="/account/forgotpassword.aspx">Forgotten your password?</a></div>
</div>
</div>
<div style="margin-bottom: 10px">
<div>
<input type="submit" name="ctl00" value="Login" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00", "", true, "Login", "", false, false))" class="btn btn-default btn-block">
</div>
</div>
<div>
问题是我得到 AttributeError:'function'对象没有属性'get'我也尝试使用XPATH找到表单但没有成功
答案 0 :(得分:0)
我在代码中犯了一个错误,所以我没有指定点击数据,这里的回调就是解决方案
def parse(self, response):
return scrapy.FormRequest.from_response(response=response,
formdata={'UserName': 'email', 'Password': 'passwd'},
clickdata={'id': 'i_b_Login'},
callback=self.after_login)