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, $ 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. כעת אתה אמור להיות התוכן של האתר משתנה מחרוזת. Note that this doesn't pull down the supporting files such as javascript or CSS. שים לב כי זה לא מורידים את הקבצים כגון תמיכה ב CSS או JavaScript. You will have to further parse the page and retrieve those seperately if you need the whole thing. תצטרך להמשיך לנתח את הדף ואת לאחזר אותם בנפרד אם אתה צריך את כל העניין.

Daily Email Updates שערי עדכונים בדוא"ל
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 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. יש לי משנה כי התקנתי WordPress בלוג באתר אחר, אבל האתר משנה של נקודות Feed RSS לאתר ההורים שלי.
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! U אני אוהבת!