"; /* create table bibel_chapter_2017 as SELECT DISTINCT anz_buch, buch, kapitel, NULL as verarbeitet FROM `bibel_lut_1984`; CREATE TABLE bibel_lut_2017 SELECT * FROM `bibel_lut_1984` WHERE 1=2; ALTER TABLE `bibel_chapter_2017` ADD `bid` INT(11) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`bid`); # Die URLs stehen im Quelltext des Dropdownfeldes auf die-bibel.de ALTER TABLE `bibel_chapter_2017` ADD `sort` INT(11) NOT NULL AFTER `bid`; # Nachdem alle Daten geholt wurden, Chapter TAbelle anpassen für LG-ON ALTER TABLE `bibel_chapter_2017` ADD `buch2` VARCHAR(500) NOT NULL AFTER `verarbeitet`; UPDATE bibel_chapter_2017 set buch2 = concat(anz_buch,' ', buch, ' ',kapitel); UPDATE `bibel_chapter_2017` set buch = buch2; ALTER TABLE `bibel_chapter_2017` DROP `sort`, DROP `anz_buch`, DROP `kapitel`, DROP `buch2`; UPDATE `bibel_chapter_2017` set buch = trim(buch); */ $db = dbconnect(); $db->query("SET NAMES 'utf8'"); $query = "SELECT bid, anz_buch, buch, kapitel, sort FROM `bibel_chapter_2017` WHERE (verarbeitet IS NULL or verarbeitet != 'Y') ORDER BY bid ASC limit 1 "; # $query = "SELECT bid, anz_buch, buch, kapitel, link # FROM `bibel_chapter_2017` # WHERE bid =1084 # "; $result = $db->query($query) or die("Cannot execute query: result"); while ($row = $result->fetch_array()) { # Für https Seiten muss man sich registrieren und mit dem VPN Programm unter Windows sich einloggen $url = "https://www.die-bibel.de/bibeln/online-bibeln/lutherbibel-2017/bibeltext/bibel/text/lesen/stelle/$row[sort]/$row[kapitel]0001/$row[kapitel]9999/"; $handle = file_get_contents($url); #$handle=file_get_contents("1mo1_bibeltext.htm"); #$handle=file_get_contents("ps119_bibeltext.htm"); #$handle=file_get_contents("ps1_bibeltext.htm"); #$handle=file_get_contents("manasse.htm"); #$handle=file_get_contents("judas1.htm"); #$handle=file_get_contents("philemon.htm"); #$handle=file_get_contents("sprueche1.htm"); #$handle=file_get_contents("sirach.htm"); #$handle=file_get_contents("jes43.htm"); $handle = strstr($handle, '
'); $handle = strstr($handle, '
", "", $handle); # Doppeltes Fett löschen: Matth 6 z.B. $handle = str_replace("", " ", $handle); # Doppelte Leerzeichen entfernen, wie oben, falls beim Strong entfernen doppelte dazukommen $handle = str_replace(' ', ' ', $handle); #echo $handle; # Mehrere Zeilenumbrüche enternen $handle = preg_replace('/(?:[ \t]*(?:\n|\r\n?)){2,}/', "\n", $handle); #echo $handle; # Bei Sirach gibt es Konstellationen wie 8 \n[7] -> Das ist aber kein Zeilenumbruch, sondern gehört zu Vers 8 zb $handle = preg_replace('#(\ \;)(\\n)(\[)#', '$1$3', $handle); $handle = preg_replace('#([0-9]) #', '$1| ', $handle); $data = explode("\n", $handle); // preg_split('#\n#', $data); Please don't # Verkorkste Überschriftszeile entfernen und dem Array neue Zeile hinzufügen unset($data[0]); if ($h3 != "") { if (!in_array(" $h3", $data)) { array_unshift($data, " $h3"); } } if ($h2 != "") { array_unshift($data, " $h2"); } if ($name != "") { array_unshift($data, " $name"); } # print_r($data); for ($i = 0; $i < count($data); $i++) { $inhalt = explode('| ', $data[$i]); $bibelstelle = "$row[anz_buch] $row[buch] $row[kapitel]"; if (isset($inhalt[1])) { $vers = trim($inhalt[0]); $inhalt_neu = trim(addslashes(html_entity_decode($inhalt[1], ENT_QUOTES))); $bibelstelle .= ", $vers"; } else { $vers = ''; $inhalt_neu = trim(addslashes(html_entity_decode($inhalt[0], ENT_QUOTES))); } # $daten[$i][0] = $vers; # $daten[$i][1] = $inhalt_neu; # In $daten[$i][1] sind auch Teilüberschriften enthalten. Diese noch separieren $sql1 = $db->query("INSERT INTO bibel_lut_2017 ( anz_buch , buch , kapitel , vers , bibelstelle , inhalt ) VALUES ( '$row[anz_buch]' , '$row[buch]' , '$row[kapitel]' , '$vers' , '$bibelstelle' , '$inhalt_neu' )"); } $sql2 = $db->query("UPDATE bibel_chapter_2017 SET verarbeitet='Y' WHERE anz_buch='$row[anz_buch]' AND buch = '$row[buch]' AND kapitel = '$row[kapitel]' "); print_r($daten); # Zufälltige Anzahl Sekunden pausieren $random = rand(3, 10); sleep($random); echo "$row[anz_buch] $row[buch] $row[kapitel]
"; # echo "UPDATE bibel_chapter_2017 SET verarbeitet='Y' WHERE anz_buch='$row[anz_buch]' AND buch = '$row[buch]' AND kapitel = '$row[kapitel]'\t ->\t $random
"; } echo ""; ?>