query("SET NAMES 'utf8'"); $query = "SELECT cid, anz_buch, buch, kapitel, link FROM `bibel_chapter_1984_html` WHERE verarbeitet IS NULL ORDER BY cid ASC "; # $query = "SELECT cid, anz_buch, buch, kapitel, link # FROM `bibel_chapter_1984_html` # WHERE cid =1084 # "; $result = $db->query( $query) or die ("Cannot execute query: result"); while ($row = $result->fetch_array()){ #$url= "https://www.die-bibel.de/bibeln/online-bibeln/lutherbibel-1984/bibeltext/bibel/text/lesen/stelle/58/10001/19999/"; $handle = file_get_contents($row['link']); $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); # 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); #echo $handle; $data = explode("\n", $handle); // preg_split('#\n#', $data); Please don't # print_r($data); for($i=1; $i < count($data)-1; $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; $sql1 = $db->query("INSERT INTO bibel_lut_1984_html ( 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_1984_html 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 "UPDATE bibel_chapter_1984_html SET verarbeitet='Y' WHERE anz_buch='$row[anz_buch]' AND buch = '$row[buch]' AND kapitel = '$row[kapitel]'\t ->\t $random
"; } ?>