search
HomeBackend DevelopmentPHP Tutorial拍拍帐号信息查询PHP

一个用于查询拍拍帐号信息的小程序,初学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>

 

Statement
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
PHP's Purpose: Building Dynamic WebsitesPHP's Purpose: Building Dynamic WebsitesApr 15, 2025 am 12:18 AM

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

PHP: Handling Databases and Server-Side LogicPHP: Handling Databases and Server-Side LogicApr 15, 2025 am 12:15 AM

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

How do you prevent SQL Injection in PHP? (Prepared statements, PDO)How do you prevent SQL Injection in PHP? (Prepared statements, PDO)Apr 15, 2025 am 12:15 AM

Using preprocessing statements and PDO in PHP can effectively prevent SQL injection attacks. 1) Use PDO to connect to the database and set the error mode. 2) Create preprocessing statements through the prepare method and pass data using placeholders and execute methods. 3) Process query results and ensure the security and performance of the code.

PHP and Python: Code Examples and ComparisonPHP and Python: Code Examples and ComparisonApr 15, 2025 am 12:07 AM

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP in Action: Real-World Examples and ApplicationsPHP in Action: Real-World Examples and ApplicationsApr 14, 2025 am 12:19 AM

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP: Creating Interactive Web Content with EasePHP: Creating Interactive Web Content with EaseApr 14, 2025 am 12:15 AM

PHP makes it easy to create interactive web content. 1) Dynamically generate content by embedding HTML and display it in real time based on user input or database data. 2) Process form submission and generate dynamic output to ensure that htmlspecialchars is used to prevent XSS. 3) Use MySQL to create a user registration system, and use password_hash and preprocessing statements to enhance security. Mastering these techniques will improve the efficiency of web development.

PHP and Python: Comparing Two Popular Programming LanguagesPHP and Python: Comparing Two Popular Programming LanguagesApr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

The Enduring Relevance of PHP: Is It Still Alive?The Enduring Relevance of PHP: Is It Still Alive?Apr 14, 2025 am 12:12 AM

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment