设为首页 收藏本站
查看: 685|回复: 0

[经验分享] 拍拍帐号信息查询PHP

[复制链接]
累计签到:6 天
连续签到:1 天
发表于 2015-8-26 11:25:16 | 显示全部楼层 |阅读模式
  一个用于查询拍拍帐号信息的小程序,初学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">拍拍帐号:&nbsp;</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">店铺综合评分&nbsp;<strong><?php echo $colligation_score['score']; ?></strong>&nbsp;分</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">店铺信用&nbsp;<strong><?php echo $credit_score; ?></strong>&nbsp;&nbsp;好评率:<strong><?php echo $reputation_rate; ?></strong></td></tr>
265     <tr><td 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>
DSC0000.png

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-104421-1-1.html 上篇帖子: PHP Socket 编程详解 下篇帖子: php写入数据中断解决方案
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表