PHP: Get the contents of a web page, RSS feed, or XML file into a string variable PHP: Get obsahu webovej stránky, RSS feed alebo XML súboru do premennej reťazca
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. Budete často potrebujú prístup k dátam, ktorá je umiestnená na inom serveri, či už píšete online RSS agregátor aneb obrazovku škrabkou na vyhľadávanie mechanizmus. PHP makes pulling this data into a string variable an extremely simple process. PHP je ťahanie tieto dáta do reťazca premennej veľmi jednoduchý proces.
You can go with the really short method: Môžete ísť s veľmi krátkou metódy:
$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. Jediný problém s touto metódou je, že niektoré webové hostí sa url prístup zablokovaný v súbore metód, z bezpečnostných dôvodov. You may be able to use this workaround method instead: Môžete byť schopní používať túto metódu riešenia miesto:
function get_url_contents($url){ Funkcia 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. Teraz by ste mali mať obsah týchto stránok v premennej reťazca. Note that this doesn't pull down the supporting files such as javascript or CSS. Všimnite si, že to nie je strhnúť podporné súbory, ako sú JavaScript alebo CSS. You will have to further parse the page and retrieve those seperately if you need the whole thing. Budete musieť ďalej analyzovať a načítanie stránky sú zvlášť, ak budete potrebovať celú vec.

Daily Email Updates Denný Svářeč
You can get our how-to articles in your inbox each day for free. Môžete si naše jak-na články vo vašej schránky každý deň zadarmo. Just enter your name and email below: Stačí zadať svoje meno a e-mail nižšie:



Problem with RSS Feed in WordPress. Problém s RSS feed do 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. Mám subdomény, ktoré som wordpress nainštalovaný na inom blogu, ale subdomény webových stránok RSS feed poukazuje na mojej nadradeného webe.
Can anyone come up with any suggestions? Môže niekto prísť s návrhmi?
Hi, Nazdar,
I've tried your hack but I always get the same result: Snažil som sa zaseknúť, ale ja si vždy rovnaký výsledok:
“Destination host forbidden” "Destination zakázané host"
How can I solve this issue? Ako môžem tento problém vyriešiť?
Thanks. Vďaka.
Thanks a lot for your simple function. Díky moc za vaše jednoduché funkcie. This really gives a lot of power to user to reuse the internet! Tento fakt dáva veľa sily, aby používateľ opätovne použiť internet!
Ofcourse the content should be pulled with prior approval! Samozrejme obsah by mal byť vytiahol s predchádzajúcim súhlasom!
i love u! i love u!