From 1757e9ca5f7ff2c4707df327dccc721733bedb26 Mon Sep 17 00:00:00 2001 From: Goeran Heinemann Date: Fri, 6 Mar 2020 13:13:11 +0100 Subject: [PATCH] =?UTF-8?q?parse=20worldometer=20mit=20todesf=C3=A4llen=20?= =?UTF-8?q?und=20genesungen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parse-worldometers.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/parse-worldometers.php b/parse-worldometers.php index 8b6bc49..79fcc75 100755 --- a/parse-worldometers.php +++ b/parse-worldometers.php @@ -2,7 +2,7 @@ query($sql); $data = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($data as $scan){ @@ -12,23 +12,33 @@ foreach ($data as $scan){ $table = $table->childNodes[1]; $data = $table->childNodes[1]; $parts = $data->childNodes; + $linetotal = array(); + $linetotal[] = $table->childNodes[2]->childNodes[0]->childNodes[0]->textContent; + $linetotal[] = intval(str_replace(",", "", $table->childNodes[2]->childNodes[0]->childNodes[2]->textContent)); $document = array(); + $document[] = $linetotal; for ($i = 0; $i < $parts->length; $i++) { $country = array(); $p2 = $parts[$i]->childNodes; $country[] = $p2[0]->textContent; - $country[] = $p2[2]->textContent; + $country[] = intval(str_replace(",", "", $p2[2]->textContent)); + $country[] =intval(str_replace(",", "", $p2[6]->textContent)); + $country[] =intval(str_replace(",", "", $p2[10]->textContent)); + $country[] =intval(str_replace(",", "", $p2[12]->textContent)); $document[] = $country; } $scanid = $scan['id']; foreach ($document as $entry){ - $sql = "INSERT INTO `data`(`scan`, `place`, `amount`) VALUES (?, ?, ?)"; + $sql = "INSERT INTO `data`(`scan`, `place`, `amount`, deaths, active, cured) VALUES (?, ?, ?, ?, ?, ?)"; $stmt = $pdo->prepare($sql); $stmt->bindParam(1, $scanid); $stmt->bindParam(2, $entry[0]); $stmt->bindParam(3, $entry[1]); + $stmt->bindParam(4, $entry[2]); + $stmt->bindParam(5, $entry[3]); + $stmt->bindParam(6, $entry[4]); $stmt->execute(); if($stmt->errorInfo()[0] != '00000' and $stmt->errorInfo()[0] != '23000' and $stmt->errorInfo()[0] != '22007') var_dump($stmt->errorInfo());