Jump to content

Website scaping using DOMDocument


Raex

Recommended Posts

Hi, I have a php code that could extract the categories and display them. However, I still can't extract the numbers that goes along with it too(without the bracket). 

 

This is my code:

<?php
$grep = new DoMDocument();
@$grep->loadHTMLFile("http://www.lelong.com.my/Auc/List/BrowseAll.asp");

$finder = new DomXPath($grep);
$class = "CatLevel1";
$nodes = $finder->query("//*[contains(@class, '$class')]");

foreach ($nodes as $node) {
    $span = $node->childNodes;
        echo $span->item(0)->nodeValue."<br>";
}
?>

This is my desired output:

Arts, Antiques & Collectibles : 9768
B2B & Industrial Products : 2342
Baby : 3453
etc...

Any help is appreciated. Thanks!

Link to comment
https://forums.phpfreaks.com/topic/290653-website-scaping-using-domdocument/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.