Nasıl PHP kullanarak çok basit bir tablo ayrıştırmak

0 Cevap

İyi günler sevgili topluluğu!

I need to build a function which parses the content of a very simple Table (with some labels and values) see the url below. I have used various ways to parse html sources. But this one is is a bit tricky! See the target i want to parse - it has some invaild markup:

Hedef: http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=644.0013008534253&SchulAdresseMapDO=194190

Peki ben bu biri ile çalıştı

<?php
require_once('config.php'); // call config.php for db connection
$filename = "url.txt"; // Include the txt file which have urls
$each_line = file($filename);
foreach($each_line as $line_num => $line)
{
    $line = trim($line);
    $content = file_get_contents($line);
    //echo ($content)."<br>";
    $pattern = '/<td>(.*?)<\/td>/si';
    preg_match_all($pattern,$content,$matches);

    foreach ($matches[1] as $match) {
        $match = strip_tags($match);
        $match = trim($match);
        //var_dump($match);
        $sql = mysqli_query("insert into tablename(contents) values ('$match')");
        //echo $match;
    }
}
?>

Eh - see the regex in line 7-11: o uymuyor!

Conclusio: i bu komut çözümleyici-parçanın yeniden zorunda. Parsercode amaçlanmıştır tam olarak ne eşleşmiyor beri - Ben Bir şekilde farklı ayrıştırmak gerekiyor. Bu tablonun sonuçlarını geri almak için amaçlanmıştır.

Can anybody help me here to get a better regex - or a better way to parse this site ... Any and all help will be greatly apprecaited.

regards zero

0 Cevap