in Education by
I want to get the search result using scrapy post request after giving the input to CP Number as 16308 https://www.icsi.in/Student/Default.aspx?TabID=100 . Here is my scrapy spider code :-- def parse(self, response): head=response.xpath('//span[@id="dnn_ctlHeader_dnnBreadcrumb_lblBreadCrumb"]/span[@class="SkinObject"]/text()').extract_first() view_gen = response.xpath('//input[@id="__VIEWSTATEGENERATOR"]/@value').extract_first() dnn= response.xpath('//input[@id="__dnnVariable"]/@value').extract_first() view_state = response.xpath('//input[@id="__VIEWSTATE"]/@value').extract_first() view_val = response.xpath('//input[@id="__EVENTVALIDATION"]/@value').extract_first() data={ '__VIEWSTATEGENERATOR':view_gen, '__dnnVariable':dnn, '__VIEWSTATE':view_state, '__EVENTVALIDATION':view_val, 'dnn$ctr410$MemberSearch$txtCpNumber':'16803', 'dnn$ctr410$MemberSearch$ddlMemberType':'0' } yield scrapy.FormRequest(response.url,formdata=data,callback=self.fun) Response DEBUG: Crawled (200) https://www.icsi.in/Student/Default.aspx?tabid=100&error=An%20unexpected%20error%20has%20occurred&content=0> (referer: https://www.icsi.in/Student/Default.aspx?TabID=100) [] JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Response DEBUG: Crawled (200) https://www.icsi.in/Student/Default.aspx?tabid=100&error=An%20unexpected%20error%20has%20occurred&content=0> (referer: https://www.icsi.in/Student/Default.aspx?TabID=100) [] Your question is how to avoid getting this error right? Try to be more specific in the future. When you want to scrape a webpage you have to inspect it all on your browser, see all parameters that are being sent with the request and make sure you are doing the same on your spider. You got lots of parameters on your code, but not all. See my code bellow which actually solves your problem: import scrapy class MySpider(scrapy.Spider): name = 'icsi' start_urls = ['https://www.icsi.in/Student/Default.aspx?TabID=100'] search_action_url = 'https://www.icsi.in/Student/Default.aspx?TabID=100' def parse(self, response): formdata = dict() for input in response.css('form#Form input'): name = input.xpath('./@name').get() value = input.xpath('./@value').get() formdata[name] = str(value) if value else '' formdata['dnn$ctr410$MemberSearch$txtCpNumber'] = '16308' formdata['__EVENTTARGET'] = 'dnn$ctr410$MemberSearch$btnSearch' return scrapy.FormRequest(self.search_action_url, formdata=formdata, callback=self.parse_search) def parse_search(self, response): scrapy.shell.inspect_response(response, self) return You were missing the parameter __EVENTTARGET, which informs the site you hit the button "Search".

Related questions

0 votes
    I have a Selenium Python automated regression test script running on our 64bit Server on IE11, Windows ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 19, 2022 in Education by JackTerrance
0 votes
    Currently I am working on this code: customer_telno = customer.find('div', 'customer_phone_number') customer_telno = ... this problem? Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    first of all,i am fairly new with spring mvc so .. how springmvc find the right class to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    @RequestMapping annotation is used to map a HTTP request method (GET or POST) to a specific class or method in the ... which will handle the respective request. A. True B. False...
asked Nov 8, 2022 in Education by JackTerrance
0 votes
    Is it possible to make a timeout of 3 seconds in a post request ? How ? My code for the moment ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    I am trying to calculate the progress of a file upload, so I was using Superagent. I was able to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 19, 2022 in Education by JackTerrance
0 votes
    This is a cURL function that can send or retrieve data. It should work with any PHP app that ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    I am new to jmeter. I have been experimenting on creating a jmeter script manually by inspecting the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    I am a very novice C# person so please dont be too hard on me Im trying to make a post request ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I am working on my first Android Application. What I am trying to do is a POST request to a REST ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I have the following HTML/ASP.NET code: Ny test Name: When using the "POST" form post method I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    What is the difference between post-database commit and post-form commit?...
asked Dec 18, 2020 in Technology by JackTerrance
0 votes
    I'm attempting to build an email scraper that takes in a csv file of urls, and returns them with ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    struts 1.x I have always defined a struts form action mapping with scope="request" unless forced into ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 23, 2022 in Education by JackTerrance
0 votes
    I have a website where all requests are redirected silently (via .htaccess) to index.php and then PHP ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 9, 2022 in Education by JackTerrance
...