[PHP] 動態顯示Yahoo奇摩拍賣的評價
![]()
今天只是突然想試寫看看,沒想到還蠻順利的。
以後就可以在網頁上動態顯示目前的拍賣評價了,Yahoo奇摩拍賣的數字變動,也會反應到網頁上面來,想要這個功能的話,只要把我這段程式改個帳號貼上去就可以囉。(當然如果不是 PHP 就行不通了)
原始程式:
<?
$YahooId = "neo288588"; //Yahoo 的拍賣帳號
$YahooRatingUrl = "http://tw.user.bid.yahoo.com/tw/show/rating?userID="; //Yahoo 的評價連結
$handle = fopen ($YahooRatingUrl.$YahooId, "r");
$contents = "";
do {
$data = fread($handle, 8192);
if (strlen($data) == 0) {
break;
}
$contents .= $data;
} while(true);
fclose ($handle);
$strLeft = "<font size=+1><b>"; //開始判別字串
$strRight = "<p>"; //結束判別字串
$posLeft = strpos($contents, $strLeft);
$posRight = strpos($contents, $strRight, $posLeft);
$YahooBidInf = substr($contents, $posLeft, $posRight-$posLeft);
?>
$YahooBidInf 就是你的「評價」、「信用卡認證」、「手機認證」的資訊,裡面存的是 HTML ,只要在你想顯示的地方加個 =$YahooBidInf ?> 就可以了。
當然如果 Yahoo 奇摩拍賣如果變動了這頁的HTML,這個程式「有可能」也因此失效了。
Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.


Comments
尚無評論。
發表您的評論