[英]how to get href value from javascript onclick attribute in python using scrapy?
<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? viewculty.aspx?FacultyID=Li9S-20151
从上面的javascript onclick
中使用scrapy从javascript onclick
提取此href viewculty.aspx?FacultyID=Li9S-20151
?
href = response.xpath('//input[@id="lnkView"]/@onclick').re_first( r'([^"]+\?[^"]+)' )
Above I'm using regex and searching for ?
以上我正在使用正则表达式并搜索
?
and surrounding unquoted symbols 及其周围未加引号的符号
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.