laden und in datenbank ablegen

This commit is contained in:
Göran Heinemann 2020-03-04 23:34:36 +01:00
parent f090308cf4
commit e2401fefbe

View File

@ -1,3 +1,15 @@
<?php
$inhalt = file_get_contents("https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Fallzahlen.html");
var_dump($inhalt);
include "config.php";
$sql = "SELECT id, title, link FROM sites WHERE active=1";
$stmt = $pdo->query($sql);
$sites = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($sites as $site){
echo 'fetching site: '.$site['title']."\n";
$inhalt = file_get_contents($site['link']);
$sql = "INSERT INTO `scans`(`site`, `content`) VALUES (?, ?)";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(1, $site['id']);
$stmt->bindParam(2, $inhalt);
$stmt->execute();
}