Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header('Content-Type: text/html; charset=utf-8');
- $grep = new DoMDocument();
- @$grep->loadHTMLFile("https://www.postme.com.my/men-1.html");
- $finder = new DomXPath($grep);
- $classCat = "level0 nav-1 active parent";
- $nodesCat = $finder->query("//*[contains(@class, '$classCat')]");
- $i = 0;
- foreach ($nodesCat as $node) {
- $span = $node->childNodes;
- $replace = str_replace("Items 1-12 of", "",$span->item(1)->nodeValue);
- echo $replace. " : ";
- }
- // Check another link using class name of "level0 nav-2 active parent"
- //repeat code
- @$grep->loadHTMLFile("https://www.postme.com.my/women.html");
- $finder = new DomXPath($grep);
- $classCat = "level0 nav-2 active parent";
- $nodesCat = $finder->query("//*[contains(@class, '$classCat')]");
- $i = 0;
- foreach ($nodesCat as $node) {
- $span = $node->childNodes;
- $replace = $span->item(1)->nodeValue;
- echo $replace. " : ";
- }
- //check another link with class name "level0 nav-3 active parent".
- //notice the incrementing nav-#?
- //I don't want to make the code long just because each link is using a slightly different class name to refer to the data.
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement