PHP: Get the contents of a web page, RSS feed, or XML file into a string variable PHP: Dapatkan isi dari suatu halaman web, RSS feed, atau file XML ke dalam sebuah variabel string
You will often have the need to access data that resides on another server, whether you are writing an online RSS aggregator or doing screen scraping for a searching mechanism. Anda akan sering memiliki kebutuhan untuk mengakses data yang berada di server lain, apakah Anda sedang menulis sebuah online RSS agregator atau melakukan menggores layar untuk mencari mekanisme. PHP makes pulling this data into a string variable an extremely simple process. PHP membuat menarik data ini ke dalam sebuah string variabel proses yang sangat sederhana.
You can go with the really short method: Anda dapat pergi dengan metode yang benar-benar pendek:
$url = “http://www.howtogeek.com”; $ url = "http://www.howtogeek.com";
$str = file_get_contents($url); $ str = file_get_contents ($ url);
The only problem with that method is that some web hosts have url access blocked in the file methods, for security reasons. Satu-satunya masalah dengan metode tersebut adalah bahwa beberapa web host memiliki akses url file diblokir di metode, untuk alasan keamanan. You may be able to use this workaround method instead: Anda mungkin dapat menggunakan metode prosedur ini sebagai gantinya:
function get_url_contents($url){ fungsi get_url_contents ($ url) ( $crl = curl_init(); $ CRL = curl_init (); $timeout = 5; $ timeout = 5; curl_setopt ($crl, CURLOPT_URL,$url); curl_setopt ($ CRL, CURLOPT_URL, $ url); curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ CRL, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt ($ CRL, CURLOPT_CONNECTTIMEOUT, $ timeout); $ret = curl_exec($crl); $ ret = curl_exec ($ CRL); curl_close($crl); curl_close ($ CRL); return $ret; return $ ret; } )
You should now have the contents of the website in a string variable. Anda seharusnya sudah memiliki isi website dalam variabel string. Note that this doesn't pull down the supporting files such as javascript or CSS. Catatan bahwa ini tidak pull down file pendukung seperti javascript atau CSS. You will have to further parse the page and retrieve those seperately if you need the whole thing. Anda akan harus mengurai lebih lanjut halaman dan mengambil orang-orang secara terpisah jika Anda memerlukan semuanya.

Daily Email Updates Harian Email Pembaharuan
You can get our how-to articles in your inbox each day for free. Anda bisa mendapatkan kita bagaimana-untuk artikel dalam kotak masuk Anda setiap hari secara gratis. Just enter your name and email below: Cukup masukkan nama dan email Anda di bawah ini:



Problem with RSS Feed in WordPress. Masalah dengan RSS Feed di WordPress.
I have a subdomain that I installed wordpress for another blog site, but the subdomain site's rss feed points to my parent site. Aku punya subdomain yang saya diinstal wordpress untuk situs blog lain, tetapi situs subdomain poin rss feed ke situs induk.
Can anyone come up with any suggestions? Can anyone datang dengan saran-saran?
Hi, Hai,
I've tried your hack but I always get the same result: Saya sudah mencoba hack Anda tetapi saya selalu mendapatkan hasil yang sama:
“Destination host forbidden” "Tujuan host dilarang"
How can I solve this issue? Bagaimana saya bisa memecahkan masalah ini?
Thanks. Terima kasih.
Thanks a lot for your simple function. Thanks a lot untuk fungsi sederhana. This really gives a lot of power to user to reuse the internet! Ini benar-benar memberikan banyak kekuatan untuk pengguna untuk menggunakan kembali internet!
Ofcourse the content should be pulled with prior approval! Ofcourse konten harus ditarik dengan persetujuan terlebih dulu!
i love u! i love u!