PHP: Get the contents of a web page, RSS feed, or XML file into a string variable PHP: Gauk į internetinį puslapį, RSS turinį ar XML failo eilutės rodiklis
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. Jūs dažnai reikia prieigos prie duomenų, kad gyvena kitame serveryje, ar rašote internete RSS skaitytuvas ar daryti ekrano grandymo dėl paieškos mechanizmą. PHP makes pulling this data into a string variable an extremely simple process. PHP leidžia dirbant šiuos duomenis į string kintamasis labai paprastas procesas.
You can go with the really short method: Jūs galite eiti su tikrai trumpas būdas:
$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. Tik problema, kad metodas yra tas, kad kai kurie kompiuteriai turi interneto prieigą URL užblokuoti failą metodus, saugumo sumetimais. You may be able to use this workaround method instead: Jūs galite naudoti šį būdą, o ne būdas:
function get_url_contents($url){ funkcija get_url_contents ($ url) ( $crl = curl_init(); $ BEL = curl_init (); $timeout = 5; $ timeout = 5; curl_setopt ($crl, CURLOPT_URL,$url); curl_setopt ($ BEL, CURLOPT_URL, $ url); curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ BEL, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt ($ BEL, 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. Dabar jūs turėtumėte turėti interneto svetainės turinį string kintamasis. Note that this doesn't pull down the supporting files such as javascript or CSS. Atkreipkite dėmesį, kad tai nėra išgriauti palaikymo failai, pavyzdžiui, JavaScript ir CSS. You will have to further parse the page and retrieve those seperately if you need the whole thing. Jūs turėsite papildomų Parse puslapyje ir gauti tuos atskirai, jei turite visa tai.

Daily Email Updates Dienos paštas Atnaujinimai
You can get our how-to articles in your inbox each day for free. Galite gauti mūsų kaip prie straipsnių į Jūsų pašto dėžutę kasdien nemokamai. Just enter your name and email below: Tiesiog įveskite vardą ir elektroninio pašto adresą žemiau:



Problem with RSS Feed in WordPress. Problem with the RSS feed į 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. Turiu subdomenas, kad aš įdiegti WordPress kito dienoraščio svetainėje, bet subdomenas svetainės RSS taškų į savo pirminės svetainės.
Can anyone come up with any suggestions? Ar kas nors sugalvoti kokių pasiūlymų?
Hi, Labas,
I've tried your hack but I always get the same result: I've tried jūsų Hack, bet gaunu tą patį rezultatą:
“Destination host forbidden” "Paskirties priimančiosios draudžiama"
How can I solve this issue? Kaip galima išspręsti šią problemą?
Thanks. Ačiū.
Thanks a lot for your simple function. Dėkojame už jūsų paprasta funkcija aikštelė. This really gives a lot of power to user to reuse the internet! Tai tikrai suteikia daug energijos, kad vartotojas panaudoti internete!
Ofcourse the content should be pulled with prior approval! Žinoma turinys turėtų būti ištrauktas iš anksto patvirtinti!
i love u! i love u!