, Web siteleri başlık ve açıklama almak utf8 tabloya kaydetmek, php / mysql

1 Cevap

Ben bu anlamaya bütün gün bugün çalışıyordum ve ben hiçbir fikrim yok.

What I want: Get the title and meta description of any kind of website.

Mysql utf tabloya bu bilgiyi kaydedin.

What the problem is? Different sites have different charsets which results in that some have chinese, some contain umlauts (german), then we have russian and so on..

Ben başkaları için değil, ben preg_match'in aynı olan domBelgesi denedim sırasında bazı işleri preg_match denedim.

Bu yapacak mevcut herhangi bir sınıf var mı?

Birisi yardımcı olabilir sayesinde umuyoruz.

1 Cevap

$data = file_get_contents( $url );
if( preg_match( '#title>([^<]+?)</title#', $data, $match ) ) {
    $result['title'] = $match[1];
}
if( preg_match( '#name="description"[^>]+?content=('|")([^"']+?)#i', $data, $match ) ) {
    $result['description'] = $match[2];
}

test değil! sadece hızla aşağı yazdı - print_r eşlemesi Hadi onlar vb maç tam olarak ne görmek için

latin1 için mysql tablo ayarlamak - bu dillerin her türlü ince olmalıdır. - O zaman% 99 çalışır çünkü ben hallettim asla.