0
<td class="headerStyle">
   <input type="image" 
       name="ctl00$ContentPlaceHolder1$gvfacletails$ctl19$lnkView" 
       id="lnkView" title="View" src="images/view.png" 
       onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ContentPlaceHolder1$gvfaculetails$ctl19$lnkView", "", false, "", "viewculty.aspx?FacultyID=Li9S-20151", false, false))">
</td>

How to extract this href viewculty.aspx?FacultyID=Li9S-20151 from above javascript onclick in python using scrapy?

2
  • 1
    a regular expression? Commented May 15, 2018 at 8:12
  • what is the best way to extract that link and to parse through callback in python scrapy? Commented May 15, 2018 at 8:37

1 Answer 1

1
href = response.xpath('//input[@id="lnkView"]/@onclick').re_first( r'([^"]+\?[^"]+)' )

Above I'm using regex and searching for ? and surrounding unquoted symbols

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.