I am trying to get the coin data of this website: http://www.tf2wh.com.
With this script:
$name = $_POST["item"];
$url = file_get_contents("http://www.tf2wh.com/allitems");
$dom = new DOMDocument();
@$dom->loadHTML($url);
$dom->saveHTML();
$code = "";
$xpath = new DOMXPath($dom);
foreach($xpath->query('//div[contains(attribute::class, "entry qual")]') as $e ) {
$code .= $e->nodeValue;
}
$code = substr($code,strpos($code,$name)-30,30);
$code = explode("(",$code);
$coins = "";
for($i = 0; $i < strlen($code[0]); $i++){
if(is_numeric($code[0][$i])){
$coins .= $code[0][$i];
}
}
echo $coins;
It works fine but there are two problems. First, its sooo slow, the time between request and response is around 15-30 seconds. Second, sometime this error occurs:
Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\steammarket\getCoins.php on line 6
How can I fix this problem with the performance issue.