delete page before downloading new one, so dead pages do not sit in the database
This commit is contained in:
parent
c6b476c4a3
commit
826e3c2b7c
1 changed files with 4 additions and 3 deletions
|
@ -31,6 +31,10 @@ foreach ($arg as $url) {
|
||||||
echo "\n";
|
echo "\n";
|
||||||
$url = preg_replace('/\/$/','',$url);
|
$url = preg_replace('/\/$/','',$url);
|
||||||
echo $url."\n";
|
echo $url."\n";
|
||||||
|
|
||||||
|
$stmt = $db->prepare('DELETE FROM indexed WHERE url = ?');
|
||||||
|
$stmt->execute([$url]);
|
||||||
|
|
||||||
$file = file_get_contents($url);
|
$file = file_get_contents($url);
|
||||||
if (!$file)
|
if (!$file)
|
||||||
continue;
|
continue;
|
||||||
|
@ -43,9 +47,6 @@ foreach ($arg as $url) {
|
||||||
|
|
||||||
echo "title: ".$title."\n";
|
echo "title: ".$title."\n";
|
||||||
|
|
||||||
$stmt = $db->prepare('DELETE FROM indexed WHERE url = ?');
|
|
||||||
$stmt->execute([$url]);
|
|
||||||
|
|
||||||
$stmt = $db->prepare('INSERT INTO indexed (title, url, content) VALUES (?, ?, ?)');
|
$stmt = $db->prepare('INSERT INTO indexed (title, url, content) VALUES (?, ?, ?)');
|
||||||
$stmt->execute([$title, $url, $document]);
|
$stmt->execute([$title, $url, $document]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue