<p class="listintro"><span id="sp"></span>其中my_encoding()是转换成你想要编码的方法!本人新手 一点小伎俩 高手见笑!</p> <p style="width:340px;height:285px;float:left;"> </p> <ol> <li> <li>function get_sub_content($str, $start, $end){ </li> <li> if ( $start == '' $end == '' ){ </li> <li> return "页面元素已经改变!"; </li> <li> } </li> <li> $str = explode($start, $str); </li> <li> $str = explode($end, $str[1]); </li> <li> return $str[0];</li> <li> }</li> <li> </li> <li>function my_encoding($data,$to){</li> <li> $encode_arr = array('UTF-8','ASCII','GBK','GB2312','BIG5','JIS','eucjp-win','sjis-win','EUC-JP');</li> <li> $encoded = mb_detect_encoding($data, $encode_arr);</li> <li> $data = mb_convert_encoding($data,$to,$encoded);</li> <li> return $data;</li> <li>}</li> <li>$doc = file_get_contents("http://video.baidu.com/v?ct=0&word=周杰伦%20site%3Awww%2Etudou%2Ecom&db=0&ty=0&rn=20&pn=0&fbl=1024");</li> <li>$doc = my_encoding($doc,"utf-8");</li> <li>$doc =get_sub_content($doc,"<div id='\"result\"'>","<br clear=");</li> <li>$str_replace = explode(" class="x">",$doc); <li>echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";</li> <li>echo "<data>";</data> </li> <li>for ($i=1; $i </li> <li>echo "<video>";</video> </li> <li>echo "<name>";</name> </li> <li>echo "";</li> <li>echo "";</li> <li>echo "<pageurl>";</pageurl> </li> <li>echo "";</li> <li>echo "";</li> <li>echo "";</li> <li>}</li> <li>echo "";</li> <li>?></li> <p style="width:100%;text-align:center;margin:10px 0"> <br> <br> </p> <p style="width:100%;text-align:center;margin:10px 0"> </p> <p class="clear"></p> </div> </li> </ol>