[Original] for the convenience of finding a room, change the rss of sohu Focus to full text. this post was last edited by PhpNewnew in 2012-07-0307: 50: 15. The house price seems to be about to rise. I recently worked overtime every day, and my daughter-in-law was responsible for finding the house, but her shit company couldn't access the internet, so she had to use ipad & nbsp; to load rss & nbsp; to watch it offline. The result was sohu focused rss & nbsp; for the convenience of finding a room for non-full-text rss & nb [original], change the sohu Focus rss to full-text rss.
This post was last edited by PhpNewnew at 07:50:15 on
The house price seems to be about to rise. I recently worked overtime every day. My daughter-in-law was responsible for looking for a house, but her dog company could not access the internet, so she had to use her ipad to load rss offline viewing, as a result, sohu focused rss is not full-text rss. for the convenience of finding a room for his wife, he wrote some code to generate full-text rss. I hope to take this opportunity to try the code to improve my life. no. paste the code directly.
Header ("Content-type: text/html; charset = utf-8 ");
Ini_set ("max_excution_time", 3600 );
$ Url = "http://sz.focus.cn/common/xml/rss/news/hot.php ";
$ NewItemArr = parseItems ($ url );
$ XmlItemContent = makeRssItemString ($ newItemArr); // regenerate the item content and replace the downloaded content with descript.
// The header and tail string of rss xml
$ XmlPre ='
Xmlns: focus = "http://house.focus.cn"
Xmlns: F = "http://house.focus.cn"
DocType = "rss"
F: docType = "rss"
>
PageIndex = ""
PageSize = "20"
RecordCount = ""
F: pageIndex = ""
F: pageSize = "20"
F: recordCount = "">
<! [CDATA [Hot News-Shenzhen site of Sohu focal net]>
Http://sz.focus.cn/newscenter/xwsy.html </link>
Http://images.house.focus.cn/img/newhouselogo.gif </url>
Hot news-Sohu focal net Shenzhen site
Http://sz.focus.cn/newscenter/xwsy.html </link>
提供最全面最及时的中国房地产新闻资讯
Copyright 2012, sohu.com Inc., all rights reserved
Zh-cn
Mon, 02 Jul 2012 21:44:21 + 0800
Mon, 02 Jul 2012 21:44:21 + 0800
Real estate integration
30
';
$ XmlAppend ='';
$ XmlOutput = $ xmlPre. $ xmlItemContent. $ xmlAppend;
Echo $ xmlOutput;
/**
* @ Param $ url
* @ Return array itemObj
*/
Function parseItems ($ url)
{
$ XmlObj = simplexml_load_file ($ url );
$ Items = $ xmlObj-> channel-> item;
$ ResultArr = array ();
Foreach ($ items as $ item ):
$ ResultArr [] = makeRssItemObj ($ item );
Endforeach;
Return $ resultArr;
}
/**
* @ Param $ item
* @ Return itemObj
*/
Function makeRssItemObj ($ item)
{
// $ Item-> link = "demo.html ";
$ UrlContent = fileGetContent ($ item-> link); // use file_get_content or socket connection if curl is not supported.
$ UrlContent = @ iconv ("gb2312", "UTF-8", $ urlContent );
// $ Content = iconv ("gb2312", "UTF-8", $ content );
Preg_match ("/id = \" newscontent \ "> ([\ d \ D] +)
/IU ", $ urlContent, $ matchArr );
$ Item-> description = $ matchArr [1];