Link.FYI

Pastebin

Create New My Pastes

Code (PHP) pasted on 2019-03-01, 21:02 Raw Source

  1. <?php
  2. foreach ($stocks as $isin => $stock) {
  3.     $platformKey = array_rand($stock['platforms']);
  4.     $platform = $stock['platforms'][$platformKey];
  5.     $uri = $platform['uri'];
  6.  
  7.     $documentSource = crawlDocument($uri);
  8.     $document = openDocument($documentSource);
  9.     $xpath = new DOMXPath($document);
  10.  
  11.     foreach ($platform['xpaths'] as $query) {
  12.         $nodes = $xpath->query($query);
  13.  
  14.         if (!is_null($nodes[0])) {
  15.             $amount = cleanNumber($nodes[0]->nodeValue);
  16.             try {
  17.                 $stmt->execute([$isin, time(), $amount]);
  18.             } catch (PDOException $e) {
  19.                 echo $e->getMessage();
  20.             }
  21.             break;
  22.         }
  23.     }
  24. }