[Original] for the convenience of finding a room, change sohu Focus rss to full text

Source: Internet
Author: User
[Original] for the convenience of finding a room, change the rss of sohu Focus to full text. 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 use [original] to find a room, and change the rss of sohu Focus to full text.
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.
PHP code
  
  
  
  
  
   
    
    <! [CDATA [Hot News-Shenzhen site of Sohu focal net]>
    Http://sz.focus.cn/newscenter/xwsy.html
    
     
Http://images.house.focus.cn/img/newhouselogo.gif
    
    Hot news-Sohu focal net Shenzhen site
    Http://sz.focus.cn/newscenter/xwsy.html
    提供最全面最及时的中国房地产新闻资讯 
    
    
     
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]; return $ item;}/*** @ param $ itemObjArr * @ return string */function makeRssItemString ($ itemObjArr) {$ result = ""; foreach ($ itemObjArr as $ itemObj): $ result. ="
  
   
"; $ Result. ="
   <! [CDATA [$ itemObj-> title]>"; $ Result. ="
   $ ItemObj-> link"; $ Result. ="
    $itemObj->description 
   "; $ Result. =" mu_rain"; $ Result. ="
   
    
$ ItemObj-> pubDate
   "; $ Result. ="
   
    
"; Endforeach; return $ result;} // ------------------------------------/*** regulary show the string or object or json. * normalized Display ** @ param $ str object instance * @ package P * @ subpackage String * @ category Putils * @ author mu_rain * @ return mixed * // -------------------------------- function pr ($ array, $ title = 'debug', $ type = 'array', $ width = '') {$ title. = date ("Y-m-d H: I: s"); $ widthStr = ""; if ($ width) $ widthStr = "width: $ width ". "px"; echo"
    
     $ Title"; Echo" "; print ("
     
");    if($type == 'json') {        $array = json_decode($array);    }    print_r($array);    print("
"); Echo" "; echo" ";} // Configure/*** get the urlContent use curl * @ package KDG * @ subpackage common * @ category mu_rain * @ author Xu Xing * // ---------------------------------- function fileGetContent ($ url) {$ ch = curl_init (); $ timeout = 30; curl_setopt ($ ch, CURLOPT_URL, $ url); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ ch, CURLOPT_CONNECTTIMEOUT, $ timeout); curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, 1); $ contents = trim (curl_exec ($ ch); curl_close ($ ch); return $ contents ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.