PHP: Get the contents of a web page, RSS feed, or XML file into a string variable PHP: Get vsebine spletne strani, RSS, ali XML datoteke v string spremenljivko
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. Boste pogosto potrebujete dostop do podatkov, ki stalno prebiva na drugem strežniku, ali pišete na spletu zbiralnik RSS ali "Narediti zaslon strganje za iskanje mehanizma. PHP makes pulling this data into a string variable an extremely simple process. PHP omogoča vlečenje te podatke v spremenljivke niz izjemno preprost proces.
You can go with the really short method: Lahko greš z zares kratko metoda:
$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. Edini problem s to metodo je, da nekateri spletni gostitelji imajo blokiran dostop url v datoteki metod, zaradi varnostnih razlogov. You may be able to use this workaround method instead: Morda boste lahko uporabljali to rešitev metodo namesto:
function get_url_contents($url){ Funkcija get_url_contents ($ url) ( $crl = curl_init(); $ = CRL curl_init (); $timeout = 5; $ timeout = 5; curl_setopt ($crl, CURLOPT_URL,$url); curl_setopt ($ RLS, CURLOPT_URL, $ url); curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ RLS, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt ($ RLS, 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. Zdaj bi morali imeti vsebino spletne strani v nizu spremenljivke. Note that this doesn't pull down the supporting files such as javascript or CSS. Upoštevajte, da to ne podirajo podporne datoteke, kot so javascript in CSS. You will have to further parse the page and retrieve those seperately if you need the whole thing. Imeli boste dodatno razčleniti stran in pridobivanje tistih ločeno, če boste potrebovali vso stvar.

Daily Email Updates Dnevni Email Updates
You can get our how-to articles in your inbox each day for free. Lahko dobite našo kako do člankov v vašo mapo »Prejeto vsak dan brezplačno. Just enter your name and email below: Preprosto vpišite vaše ime in e-pošto spodaj:



Problem with RSS Feed in WordPress. Težava z RSS Feed v 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. Imam poddomeno, da sem namestil wordpress blog za drugo mesto, vendar poddomene spletnega mesta rss feed točk na svoj nadrejenega mesta.
Can anyone come up with any suggestions? Lahko kdo prišel gor s kakršnimi koli predlogi?
Hi, Živjo,
I've tried your hack but I always get the same result: Ive 'preizkušen vaš kramp vendar sem vedno dobil enak rezultat:
“Destination host forbidden” "Destination prepovedana host"
How can I solve this issue? Kako rešiti to vprašanje?
Thanks. Hvala.
Thanks a lot for your simple function. Hvala veliko zakaj vaš enostavno delovanje. This really gives a lot of power to user to reuse the internet! To res daje veliko moči, da uporabnik ponovno internet!
Ofcourse the content should be pulled with prior approval! Seveda vsebino je treba izvleči s predhodno odobritvijo!
i love u! i love u!