I would like to scrape the table t-02
from https://wyniki.tge.pl/wyniki/rdn/ with HTML DOM Parser.
I created simple code but I was getting errors:
Fatal error: Call to a member function find() on null in /Users/piotrek/Sites/foo/index.html on line 3
My first code:
<?php
include ("simple_html_dom.php");
$html=file_get_html("https://wyniki.tge.pl/pl/wyniki/rdn/");
$tables=$html->find("table[@class=t-02]");
foreach($tables->find("tr") as $a) {
foreach($a->find("td") as $element) {
echo $element;
}
}
?>
I changed the code to print innertext and it worked:
<?php
include_once ("simple_html_dom.php");
$html=file_get_html("https://wyniki.tge.pl/pl/wyniki/rdn/");
$title=$html->find("table[@class=t-02]",0)->innertext;
echo $title
?>
I changed only code so what was wrong with first approach? What was the reason of fatal error?