【发布时间】:2015-08-11 08:24:49
【问题描述】:
我是网络爬虫的新手。我正在尝试使用 java 抓取网页,但遇到了问题。我需要在其href 是javascript 函数的“HTML 标记”中获取链接。我不知道如何在 javascript 函数中获取链接。这里是html源码和javascript源码。
HTML
<a href='javascript:ShowPostGridUnique(205316,0);'>link</a>
JSShowPostGridUnique
function ShowPostGridUnique(parentpostid, pageShow) {
//alert(parentpostid);
var divid;
divid = 'divPostContent' + parentpostid;
if (document.getElementById(divid).className == 'divGridShow') {
document.getElementById(divid).className = 'divGridHide';
document.getElementById(divid).innerHTML = '';
}
else {
document.getElementById(divid).className = 'divGridShow';
// call server side method
PageMethods.divParentInnerHtml( parentpostid, pageShow, CallSuccessShowPost, CallFailedAlert, parentpostid);
try {
divid = 'TDtitle' + parentpostid;
document.getElementById(divid).className = 'TDtitle';
divid = 'TDPage' + parentpostid;
document.getElementById(divid).className = 'TDtitle';
}
catch (err) {
//Handle errors here
}
}
}
如何获取href的链接?谢谢。
【问题讨论】:
标签: javascript java html web-crawler