Ad Block 1
avatar
FEOR lista

Guest 100 15th May, 2019

                                           
                         <?php

$base_url = "https://www.ksh.hu/docs/szolgaltatasok/hun/feor08";
$url = $base_url . "/feorlista.html";
$content = file_get_contents($url);

$old_libxml_error = libxml_use_internal_errors(true);

$document = new \DOMDocument();
$document->loadHTML($content);

libxml_use_internal_errors($old_libxml_error);

$nodes = (new DOMXPath($document))->query('//a[contains(@class, "occ")]');
$data = [];

for ($i = 0; $i < $nodes->length; $i++) {
    $data[] = [
        'main_category' => $nodes[$i]->parentNode->parentNode->parentNode->parentNode->parentNode->parentNode->parentNode->firstChild->textContent,
        'category'      => $nodes[$i]->parentNode->parentNode->parentNode->parentNode->parentNode->firstChild->textContent,
        'sub_category'  => $nodes[$i]->parentNode->parentNode->parentNode->firstChild->textContent,
        'name'          => $nodes[$i]->textContent,
        'href'          => $base_url . "/" . $nodes[$i]->getAttribute('href'),
    ];
}

header('Content-Type: application/json');
echo json_encode($data);
                      
                                       
To share this paste please copy this url and send to your friends
RAW Paste Data
Ad Block 2

Comments

Authentication required

You must log in to post a comment.

Log in
    There are no comments yet.