0

I am having some code and getting HTTP 500 Error. A bit getting confused. I need to extract from the web of weather cast weather digit information and add in the website.

Here is a code:

orai_class.php

<?php
    
    Class orai{
        
    var $url;
        
        
        
    function generate_orai($url){   
    
    
    $html = file_get_contents($url);
    
    $classname = 'wi wi-1';
    $dom = new DOMDocument;
    $dom->loadHTML($html);
    $xpath = new DOMXPath($dom);
    $results = $xpath->query("//*[@class='" . $classname . "']");
    
    $i=0;
    foreach($results as $node)
    {
    
    
    if ($results->length > 0) {
        $array[] = $results->item($i)->nodeValue;
    }
    $i++;
    }
    
    return $array;  
        
            
    }   
     }
    
    
    ?>


    
    

index.php

<?php

include("orai.class.php");

$orai = new orai();

print_r($orai->generate_orai('https://orai.15min.lt/prognoze/vilnius'));

?>

Thank You.

ADyson
  • 57,178
  • 14
  • 51
  • 63
Justinas
  • 35
  • 1
  • 6
  • You're not using cURL here (you seem to be using file_get_contents instead) - I've edited it for you. – ADyson Jul 22 '21 at 14:57
  • Anyway 500 Internal Server Error is a generic error message informing you that the server crashed while processing the request. Beyond that, it's (intentionally) meaningless, and is of very little use for debugging. You need to check the error logs on the server to try and find the underlying exception message. Once you've got that, you stand a chance of identifying the problem. – ADyson Jul 22 '21 at 14:58
  • Or you can temporarily turn on error reporting (but if it's a live server, make sure you don't leave it on): https://stackoverflow.com/questions/845021/how-can-i-get-useful-error-messages-in-php – ADyson Jul 22 '21 at 14:59

0 Answers0