<?php
class partsouq
{
    static function search($vin)
    {
        libxml_use_internal_errors(true);
        $html=file_get_contents("https://partsouq.com/en/search/all?q=$vin");
        $doc = new DOMDocument();
        $doc->loadHTML($html);
        $finder = new DomXPath($doc);
        $img = $finder->query("//button[contains(@id,\"yw0\")]");
        $vv=array();
        $vv["data"]=array();
        if($img->length==1){
            $doc1 = new DOMDocument();
            $doc1->loadHTML('<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'.$img->item(0)->getAttribute("data-content"));
            $finder1 = new DomXPath($doc1);
            $tab = $finder1->query("//tr");
            foreach ($tab as $node){
                $vv["data"][0][explode(":",$node->childNodes->item(0)->textContent)[0]]=mb_convert_encoding(str_replace("  "," ",str_replace(";"," | ",$node->childNodes->item(1)->textContent)), 'HTML-ENTITIES', 'UTF-8');
            }
        }
        return $vv;
    }
}