I'm using cobra to get some specific data from a website. According to the codes from http://www.benjysbrain.com/misc/cobra/,
I can get the data by document.getElementById(elementId) after iterating the whole webpage. It is a heavy workload comparing with a few data I need. So, I use another approach, i.e. only parse my interested part (nodes) . i.e.
I have tried to parse some parent nodes/element of the interested element, but also failed. Does anyone have the a solution? Any suggetion or help will be very appreciated.
-edited by Viking
_
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi All,
I'm using cobra to get some specific data from a website. According to the codes from http://www.benjysbrain.com/misc/cobra/,
I can get the data by document.getElementById(elementId) after iterating the whole webpage. It is a heavy workload comparing with a few data I need. So, I use another approach, i.e. only parse my interested part (nodes) . i.e.
HTMLDocument document = (HTMLDocumentImpl) dbi.createDocument(inputSource);
((HTMLDocumentImpl)document).addDocumentNotificationListener(this);
HtmlParser parser = new HtmlParser(uaContext, document);
HTMLDivElement infoNode = new HTMLDivElementImpl("myTab1_Content0");
doTree((Node) infoNode);
parser.parse(lineNumberReader, infoNode);
But I can 't get the data by document.getElementById("myTab1_Content0"); The ralated part of html is following:
<div id="myTab1_Content0" >
<div class="business_card" >
<dl>
<script>
if (saler.dyPropKey){
for (var i=0;i<saler.dyPropKey.length;i++){
document.write('<dd><span>'+ saler.dyPropKey_ +':</span><p>'+ saler.dyPropValue +'</p></dd>');
}
}
</script>
</dl>
</div>
I have tried to parse some parent nodes/element of the interested element, but also failed. Does anyone have the a solution? Any suggetion or help will be very appreciated.
-edited by Viking
_
Is this something XPath could handle? I've only used XPath to extract nodes by type, but there might be a way to look by attribute.
Benjy