PHP: Get the contents of a web page, RSS feed, or XML file into a string variable PHP: отримати вміст веб-сторінки, RSS-канал, або XML-файлу у послідовну змінну
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. Ви будете часто необхідний доступ до даними, який знаходиться на іншому сервері, будь ви пишете онлайн агрегатор RSS або робити чищення екрану для пошуку механізму. PHP makes pulling this data into a string variable an extremely simple process. PHP робить потягнувши ці дані в рядок мінлива дуже простий процес.
You can go with the really short method: Ви можете перейти зі справді короткий спосіб:
$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. Єдина проблема до цього методу є те, що деякі веб-хостингу мають доступ до заблокованих URL у файлі методами, з міркувань безпеки. You may be able to use this workaround method instead: Ви можете використовувати цей метод замість обходу:
function get_url_contents($url){ Функція 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, $ таймаут); $ret = curl_exec($crl); $ Ret = curl_exec ($ CRL); curl_close($crl); curl_close ($ CRL); return $ret; повернути $ RET; } )
You should now have the contents of the website in a string variable. Тепер ви повинні мати зміст веб-сайту в рядку змінних. Note that this doesn't pull down the supporting files such as javascript or CSS. Зауважимо, що це не знести допоміжні файли, такі як JavaScript і CSS. You will have to further parse the page and retrieve those seperately if you need the whole thing. Вам доведеться подальшого розбору сторінки і отримати їх окремо, якщо вам потрібна цілком.

Daily Email Updates Email Щоденні оновлення
You can get our how-to articles in your inbox each day for free. Ви можете отримати наші довідкові статті у Вашу поштову скриньку щодня безкоштовно. Just enter your name and email below: Просто введіть ваші ім'я та адресу електронної пошти нижче:



Problem with RSS Feed in WordPress. Проблема з RSS-канал в 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. У мене є субдомен, що я встановив ще на WordPress блог на сайті, а RSS Feed субдомени сайту вказує на мій батько сайті.
Can anyone come up with any suggestions? Чи можна придумати будь-які пропозиції?
Hi, Привіт,
I've tried your hack but I always get the same result: Я намагався зламати ваш, але я завжди отримаєте той самий результат:
“Destination host forbidden” "Напрямок приймають заборонені"
How can I solve this issue? Як можна вирішити цю проблему?
Thanks. Спасибо.
Thanks a lot for your simple function. Велике спасибі за вашу просту функцію. This really gives a lot of power to user to reuse the internet! Це дійсно дає багато енергії, щоб користувач для повторного використання в Інтернет!
Ofcourse the content should be pulled with prior approval! Звичайно зміст треба тягнути за попередньою згодою!
i love u! I Love U!