0

I tried all the Id and class options. I tried to pull the element using the last tag. But it writes [object Object] expression to the console. This object cannot be fragmented in any way.

var webpage = require('webpage');
var page = webpage.create();

page.open('https://arsiv.mackolik.com/Canli-Sonuclar',function (){

    result = page.evaluate(function (){
        return document.getElementsByTagName("tbody");
    });

    console.log(result);
    phantom.exit();
})

result is [object Object].

How can I access the data in tbody? I get an error when I try to parse it with foreach and print it to the console.

  • `result.innerHTML` will give you the HTML. `result.querySelectorAll('tr')` will give you all the `tr` elements in the tbody – Adam H Mar 06 '23 at 20:02
  • @AdamH result.innerHTML give undefined. Also result.queryselectorall('tr') give TypeError: 'undefined' is not a function (evaluating 'result.querySelectorAll('tr')') hello.js:10 :/modules/webpage.js:281 – furkan aydınlı Mar 06 '23 at 20:15
  • `getElementsByTagName()` returns a list of multiple elements. You need to index it to access a specific element, or loop over them to process all. – Barmar Mar 06 '23 at 20:35

0 Answers0