O çıktı tarayıcı penceresinde görüntülenen alır böylece php den wget nasıl çalıştırılır?

4 Cevap

O çıktı tarayıcı penceresinde görüntülenen alır böylece php den wget nasıl çalıştırılır?

4 Cevap

Sadece file_get_contents yerine kullanabilirsiniz. Onun çok daha kolay.

echo file_get_contents('http://www.google.com');

Eğer wget kullanmak varsa, gibi bir şey deneyebilirsiniz:

$url = 'http://www.google.com';
$outputfile = "dl.html";
$cmd = "wget -q \"$url\" -O $outputfile";
exec($cmd);
echo file_get_contents($outputfile);

exec işlev wget çalıştırmak için kullanılabilir. Ben basit bir dosya indirme için daha sonra wget hiç kullanmadım ama sen dosya içeriğini o çıkışı yapmak wget ne verirseniz bağımsız değişkenleri olacaktır. Exec ikinci parametre / değişken bir dizi olacak ve bu dizi wget çıkışı ile satır satır doldurulacaktır.

Böylece gibi bir şey olurdu:

<?php

exec('wget http://google.com/index.html -whateverargumentisusedforoutput', $array);

echo implode('<br />', $array);

?> 

The manual page for exec probably explains this better: http://php.net/manual/en/function.exec.php

Çalışıyor

<?php

    system("wget -N -O - 'http://google.com")

?>

Don't try that on most serversr, they should be blocked from running commands like wget! file_get_contents has just replaced crappy iframe my client insisted on having with this and a quick

<?php

$content = file_get_contents('http://www.mysite.com');
$content = preg_replace("/Comic Sans MS/i", "Arial, Verdana ", $content);
$content = preg_replace("/<img[^>]+\>/i", " ", $content); 
$content = preg_replace("/<iframe[^>]+\>/i", " ", $content);  
$echo $content;

?>

Daha sonra yazı, görüntüleri değiştirmek için vb görüntüleri ve iframe kaldırmak ... ve benim site zamankinden daha iyi bakıyor! (Evet kod benim biraz parlak değil biliyorum ama benim için çok büyük bir gelişme ve can sıkıcı biçimlendirmeyi kaldırır!)