标签:php
之前写了一片有关于阿里大数据比赛排名获取的文章(http://blog.csdn.net/dliyuedong/article/details/22849163),使用的是java,代码虽然不是很多,但是确实也不少.这几天简单的学习了一下php,发现php确实适合建立小网站,没有java(jsp)那样多的代码,但是java毕竟有java的优点,这里也不做说明,大家可以google一下.下面贴出使用php获取阿里大数据比赛的php代码:
<html>
<head>
<title>阿里大数据比赛排名</title>
</head>
<body>
<div style="text-align: center;">
<h2>阿里大数据比赛排名</h2>
<table style="margin-left: auto; margin-right: auto; width: 90%;"
border="1">
<tr>
<td align="center" style="color: green;">队名</td>
<td align="center" style="color: green;">学校</td>
<td align="center" style="color: green;">F1</td>
<td align="center" style="color: green;">准确率</td>
<td align="center" style="color: green;">召回率</td>
<td align="center" style="color: green;">最优提交时间</td>
<td align="center" style="color: green;">排名</td>
</tr>
<?php
$number = 0 ;
$ustc_teams = 0;
for($i=1;$i<11;$i++) {
$abc = file_get_contents("http://102.alibaba.com/competition/addDiscovery/queryTotalRank.json?pageIndex=". $i ."&&pageSize=20");
$content = json_decode($abc);
$arr=array();
foreach($content->returnValue->datas as $k=>$w)
$arr[$k]=$w;
foreach ($arr as $item )
{
foreach ($item as $k=>$w)
${"$k"} = $w ;
$count++ ;
if (strpos($university,"中国科学技术大学") !== false){
echo '<tr style="background-color: #888888;"> ';
$ustc_teams++;
}
elseif ($count % 2==1)
echo '<tr style="background-color: #eeeeee;"> ';
else
echo "<tr>";
echo '<td align="center" style="color: red;">'.$teamName.'</td>' ;
echo '<td align="center">'. $university .'</td>' ;
echo '<td align="center" style="padding-left:4px;padding-right:4px;">'.number_format($score *100,3).'%</td>' ;
echo '<td align="center" style="padding-left:4px;padding-right:4px;">'.number_format($precision*100,3).'%</td>' ;
echo '<td align="center" style="padding-left:4px;padding-right:4px;">'.number_format($recall*100,3).'%</td>' ;
echo '<td align="center" >'.$dateString.'</td>' ;
echo '<td align="center" style="color: blue;" >'.$rank.'</td>';
echo "</tr>";
}
}
?>
</table>
<br>
<?php
echo "科大进入排名队伍一共有 <font color=red>" . $ustc_teams ."</font> 支";
?>
<br>
</div>
</body>
</html>标签:php
原文地址:http://blog.csdn.net/dliyuedong/article/details/32936273