Home > Backend Development > PHP Tutorial > 拍拍帐号信息查询PHP

拍拍帐号信息查询PHP

WBOY
Release: 2016-06-23 14:36:54
Original
1062 people have browsed it

一个用于查询拍拍帐号信息的小程序,初学php写的比较烂。

  1 <?php  2     include_once('./simple_html_dom.php');  3   4     $info_detail = array();            //卖家资料  5     $colligation_score = array();    //综合评分  6     $service_status = array();        //店铺近30天服务状况  7     $comp_rate = array();            //投诉率  8     $refund_rate = array();            //退款率  9      10     $is_display_credit = false;        //是否显示信用模块 11     $credit_score = '';                //信用分数 12     $reputation_rate = '';            //好评率 13      14     $last_week = array();            //最近一周 15     $last_month = array();            //最近一月 16     $last_six_months = array();        //最近半年 17     $total = array(); 18      19     $qq = isset($_POST['qq']) ? $_POST['qq'] : ''; 20     if($qq != ''){ 21         $info_detail['account'] = $qq; 22         $info_detail['detail link'] = "http://shop.paipai.com/cgi-bin/creditinfo/view?uin=" . $qq . "&flag=1"; 23          24 /*        $ch = curl_init(); 25         curl_setopt($ch, CURLOPT_URL, $info_detail['detail link']); 26         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 27         curl_setopt($ch, CURLOPT_HEADER, 0); 28         $result = curl_exec($ch); 29         curl_close($ch); 30 */ 31         $result = file_get_contents($info_detail['detail link']); 32          33         $html = new simple_html_dom(); 34         $html->load($result); 35      36         //卖家资料 37         $ele = $html->find('div[class=name]'); 38         if($ele == null){ 39             echo "<script type=\"text/javascript\">location.href='./index.php'</script>"; 40         } 41          42         $info_detail['nick'] = $ele[0]->next_sibling()->plaintext; 43         $info_detail['area'] = $ele[1]->next_sibling()->plaintext; 44         $info_detail['time'] = $ele[2]->next_sibling()->plaintext; 45          46         //店铺综合评分 47         $colligation_score['score'] = $html->find('div[class=score module] h1 span.times strong', 0)->plaintext; 48         $ele = $html->find('div[class=score module] div.nav ul li'); 49         $colligation_score['conform'] = $ele[0]->children[1]->children[0]->plaintext; 50         $colligation_score['attitude'] = $ele[1]->children[1]->children[0]->plaintext; 51         $colligation_score['delivery speed'] = $ele[2]->children[1]->children[0]->plaintext; 52          53  54         //店铺近30天服务状况 55         $ele = $html->find('div[class=score module shop_about] div div ul li'); 56         $service_status['backmoney speed'] = $ele[0]->children[1]->children[0]->plaintext; 57         $service_status['backmoney rate'] = $ele[1]->children[1]->children[0]->plaintext; 58         $service_status['complaint handing speed'] = $ele[2]->children[1]->children[0]->plaintext; 59         $service_status['complaint rate'] = $ele[3]->children[1]->children[0]->plaintext; 60          61          62         //投诉率 63         $ele = $html->find('div[class=center_block small_table] div[class=score module shop_about] div ul li'); 64         $comp_rate['commercial quality'] = $ele[0]->children[1]->children[0]->plaintext;    //商品质量原因 65         $comp_rate['stockout'] = $ele[1]->children[1]->children[0]->plaintext;                //缺货原因     66         $comp_rate['attitude'] = $ele[2]->children[1]->children[0]->plaintext;                //服务态度原因     67         $comp_rate['delivery speed'] = $ele[3]->children[1]->children[0]->plaintext;        //发货速度原因 68          69         //退款率 70         $ele = $html->find('div[class=center_block small_table refund] div[class=score module shop_about] div ul li'); 71         $refund_rate['commercial quality'] = $ele[0]->children[1]->children[0]->plaintext; 72         $refund_rate['stockout'] = $ele[1]->children[1]->children[0]->plaintext; 73         $refund_rate['attitude'] = $ele[2]->children[1]->children[0]->plaintext; 74          75         //店铺信用率 76         $ele = $html->find('div[class=score module shop_score] h1.title', 0); 77         if($ele != null) { 78             $is_display_credit = true;     79             $credit_score = $ele->children[2]->score; 80             $reputation_rate = $ele->children[3]->children[0]->plaintext; 81              82             $ele = $html->find('div[class=score module shop_score] div.table table tr'); 83             $last_week['good'] = $ele[1]->children[1]->innertext; 84             $last_week['average'] = $ele[1]->children[2]->innertext; 85             $last_week['fail'] = $ele[1]->children[3]->innertext; 86          87             $last_month['good'] = $ele[2]->children[1]->innertext; 88             $last_month['average'] = $ele[2]->children[2]->innertext; 89             $last_month['fail'] = $ele[2]->children[3]->innertext; 90              91             $last_six_months['good'] = $ele[3]->children[1]->innertext; 92             $last_six_months['average'] = $ele[3]->children[2]->innertext; 93             $last_six_months['fail'] = $ele[3]->children[3]->innertext; 94              95             $total['good'] = $ele[4]->children[1]->innertext; 96             $total['average'] = $ele[4]->children[2]->innertext; 97             $total['fail'] = $ele[4]->children[3]->innertext; 98         } 99         100         $html->clear();101 102 103         104     }105 106 ?>107 108 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">109 <html xmlns="http://www.w3.org/1999/xhtml">110 <head>111 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />112 <title>拍拍帐号信息查询</title>113 114 <style type="text/css">115 116 *{117     font-size:13px;118 }119 120 a{121     color:#00f;122     text-decoration:none;123 }124 125 a:hover{126     color:#f60;127 }128 129 strong{130     color:#FF4E00;131 }132 133 134 135 #query_box{136     margin:20px auto;137     width:60%;138     line-height:50px;139     text-align:center;140     border:1px solid #ddd;141 }142 143 144 #query_form input#qq{145     width:300px;146     height:20px;147     line-height:20px;148 }149 150 #query_form button.btn_query{151     width:50px;152     height:25px;153 }154 155 #query_result{156     margin:20px auto;157     width:60%;    158 }159 160 #query_result table, #query_result table tr, #query_result table td{161     border:1px solid #ccc;162 }163 164 #query_result table {165     width:100%;166     border-collapse:collapse;167 }168 169 #query_result table td{170     padding:5px;171 }172 173 .tle {174     background-color:#ddd;175     line-height:30px;176     font-weight:bold;177 }178 179 .item_title{180     width:20%;181 }182 183 #credit, #credit tr, #credit td{184     border:none;185     text-align:center;186 }187 188 .good_ico, .average_ico, .fail_ico{189     width:30px;190     line-height:20px;191     padding-left:20px;192     margin:0px auto;193     display:block;194 }195 196 .good_ico {197     background:url(./images/bg_shop_credit_rating.png) scroll 0px -270px;198 }199 200 .average_ico{201     background:url(./images/bg_shop_credit_rating.png) scroll 0px -290px;202 }203 204 .fail_ico{205     background:url(./images/bg_shop_credit_rating.png) scroll 0px -310px;206 }207 208 209 </style>210 211 </head>212 213 <body>214 <div id="query_box">215 <form id="query_form" action="./index.php" method="post">216     <label for="qq">拍拍帐号: </label><input type="text" id="qq" name="qq" />217     <button class="btn_query" type="submit">查询</button>218 </form>219 </div>220 221 <?php if($qq != '') {?>222 <div id="query_result">223 <table>224     <tr><td class="tle" colspan="4">卖家资料</td></tr>225     <tr><td class="item_title">拍拍帐号</td><td colspan="3"><?php echo $info_detail['account']; ?></td></tr>226     <tr><td class="item_title">卖家昵称</td><td colspan="3"><?php echo $info_detail['nick']; ?></td></tr>227     <tr><td class="item_title">所属地区</td><td colspan="3"><?php echo $info_detail['area']; ?></td></tr>228     <tr><td class="item_title">开店时间</td><td colspan="3"><?php echo $info_detail['time']; ?></td></tr>229     <tr><td class="item_title">详细信息</td><td colspan="3"><a target="_blank" href="<?php echo $info_detail['detail link']; ?>"><?php echo $info_detail['detail link']; ?></a></td></tr>230     231     <tr><td class="tle" colspan="4">店铺综合评分 <strong><?php echo $colligation_score['score']; ?></strong> 分</td></tr>232     <tr><td class="item_title">商品与描述相符</td><td colspan="3"><strong><?php echo $colligation_score['conform']; ?></strong>分</td></tr>233     <tr><td class="item_title">卖家的服务态度</td><td colspan="3"><strong><?php echo $colligation_score['attitude']; ?></strong>分</td></tr>234     <tr><td class="item_title">卖家发货的速度</td><td colspan="3"><strong><?php echo $colligation_score['delivery speed']; ?></strong>分</td></tr>235 236     <tr><td class="tle" colspan="4">店铺近30天服务状况</td></tr>237     <tr><td class="item_title">平均退款速度</td><td colspan="3"><strong><?php echo $service_status['backmoney speed']; ?></strong></td></tr>238     <tr><td class="item_title">退款率</td><td colspan="3"><strong><?php echo $service_status['backmoney rate']; ?></strong></td></tr>239     <tr><td class="item_title">平均投诉处理速度</td><td colspan="3"><strong><?php echo $service_status['complaint handing speed']; ?></strong></td></tr>240     <tr><td class="item_title">投诉率</td><td colspan="3"><strong><?php echo $service_status['complaint rate']; ?></strong></td></tr>241     242     <tr><td class="tle"  colspan="2">投诉率</td><td class="tle"  colspan="2">退款率</td></tr>243     <tr>244         <td class="item_title">商品质量原因</td><td><strong><?php echo $comp_rate['commercial quality']; ?></strong></td>245         <td class="item_title">商品质量原因</td><td><strong><?php echo $refund_rate['commercial quality']; ?></strong></td>246     </tr>247     248     <tr>249         <td class="item_title">缺货原因</td><td><strong><?php echo $comp_rate['stockout']; ?></strong></td>250         <td class="item_title">缺货原因</td><td><strong><?php echo $refund_rate['stockout']; ?></strong></td>251     </tr>252     253     <tr>254         <td class="item_title">服务态度原因</td><td><strong><?php echo $comp_rate['attitude']; ?></strong></td>255         <td class="item_title">服务态度原因</td><td><strong><?php echo $refund_rate['attitude']; ?></strong></td>256     </tr>257     258     <tr>259         <td class="item_title">发货速度原因</td><td  colspan="3"><strong><?php echo $comp_rate['delivery speed']; ?></strong></td>260     </tr>261 262     263     <?php if($is_display_credit) { ?>264     <tr><td class="tle" colspan="4">店铺信用 <strong><?php echo $credit_score; ?></strong>  好评率:<strong><?php echo $reputation_rate; ?></strong></td></tr>265     <tr><td style="padding:0px;" colspan="4">266         <table id="credit">267             <tr><td></td><td><span class="good_ico">好评</span></td><td><span class="average_ico">中评</span></td><td><span class="fail_ico">差评<span></td></tr>268             <tr><td class="item_title">最近一周</td><td><strong><?php echo $last_week['good']; ?></strong></td><td><strong><?php echo $last_week['average']; ?></strong></td><td><strong><?php echo $last_week['fail']; ?></strong></td></tr>269             <tr><td class="item_title">最近一月</td><td><strong><?php echo $last_month['good']; ?></strong></td><td><strong><?php echo $last_month['average']; ?></strong></td><td><strong><?php echo $last_month['fail']; ?></strong></td></tr>270             <tr><td class="item_title">最近半年</td><td><strong><?php echo $last_six_months['good']; ?></strong></td><td><strong><?php echo $last_six_months['average']; ?></strong></td><td><strong><?php echo $last_six_months['fail']; ?></strong></td></tr>271             <tr><td class="item_title">总计</td><td><strong><?php echo $total['good']; ?></strong></td><td><strong><?php echo $total['average']; ?></strong></td><td><strong><?php echo $total['fail']; ?></strong></td></tr>272         </table>273     </td></tr>274     <?php } ?>275 </table>276 </div>277 <?php } ?>278 </body>279 </html>
Copy after login

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template