我一直在使用PHP的simplexml_load_file解析大量的RSS提要,它就像一個魅力。 現在我正在嘗試爲金融時報的RSS提要做同樣的事情。當我做...如何在PHP中解析RSS非XML Feed?
$rss = simplexml_load_file("http://www.ft.com/rss/world");
...我得到:
Warning: simplexml_load_file(): http://www.ft.com/rss/world:11: parser error : Opening and ending tag mismatch: link line 8 and head in rss.php on line 6
Warning: simplexml_load_file(): oat:left;margin-right:20px;margin-top:3px;width:35px;height:31px;}</style></head in rss.php on line 6
Warning: simplexml_load_file():^in rss.php on line 6
Warning: simplexml_load_file(): http://www.ft.com/rss/world:37: parser error : Opening and ending tag mismatch: input line 37 and li in rss.php on line 6
Warning: simplexml_load_file():^in rss.php on line 6
和很多很多的警告(約100)。
我已經搜索了Stackoverflow的答案,但我找不到任何似乎適用於這種情況。我在這裏錯過了什麼?
您是否嘗試過使用FT feed?我省略了LIBXML擴展,但它仍然是一樣的。 vardump返回false。請注意,此代碼適用於大多數其他Feed ... – TheBigDoubleA
您似乎從URL獲取HTML。嘗試使用file_get_contents獲取它並回顯它以查看您的Web服務器正在接收的內容。也許他們正在過濾一些用戶代理以獲取其供稿。 – Othi
你是對的:我得到一個html頁面,這是一個:http://www.ft.com/gfdlgjfdglkfjdgd。我該如何克服這一點? – TheBigDoubleA