simple html dom, scraping error Notice: Trying to get property of non-object in C:\xampp\htdocs\scraper\au_div_puller.php on line 60 - Stack Overflow

PHOTO EMBED

Wed Sep 02 2020 10:27:42 GMT+0000 (Coordinated Universal Time)

Saved by @sailomtaaley #php

$table = $html->find('table', 0); // ID LOCK IE TABLE 0 (first table) Get the first table ??
foreach($table ->find('tr') as $tr) {     // Foreach row in the table!
    if($td = $tr->find('td', 0)) {
        $Ex_Date = $td->plaintext; // Find the first TD (starts with 0)
        // ... and so on for each variable
content_copyCOPY

เนื่องจากไม่สามารถรับประกันได้ว่า find('td',0) จะหาค่าได้เสมอไป หากไม่พบค่า จะเกิด err เมื่อใช้ plaintext จึงใส่ if เพื่อตรวจสอบก่อนว่ามีข้อมูลไหม ก่อนจะใช้ plaintext

https://stackoverflow.com/questions/47342481/simple-html-dom-scraping-error-notice-trying-to-get-property-of-non-object-in/47343369