Menu

how to directly get the data held by js

Help
Viking Yu
2010-05-04
2013-04-29
  • Viking Yu

    Viking Yu - 2010-05-04

    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

    _

     
  • Benjy

    Benjy - 2010-05-13

    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

     

Log in to post a comment.