0
我試圖使用scrapy FormRequest對於該特定網站 https://www.ventureradar.com/ASP與scrapy
<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>
蜘蛛代碼perfom登錄網登錄:
import scrapy
import json
class VentureRadar(scrapy.Spider):
name = 'vr'
start_urls = ['https://www.ventureradar.com/']
def parse(self, response):
return scrapy.FormRequest.from_response(response=response,
clickdata=self.after_login,
formdata={'UserName': '[email protected]', 'Password': 'batna005'})
def after_login(self, response):
self.logger.info("you are at %s" % response.url)
問題是,我得到AttributeError:'function'對象沒有屬性'get'我也嘗試使用XPATH定位表單但沒有成功
所以,你試圖竊取數據,該組織已經花了很多時間解決,資金和專業知識生成? –