


PHP's cURL implements mobile phone number location query function
本文主要和大家分享PHP之cURL实现手机号码归属地查询功能,希望能帮助到大家。
1、代码如下:
index.html
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <title>手机号码归属地查询</title> <style type="text/css"> *{margin: 0;padding: 0;border: 0;} body{font-family: 微软雅黑;width: 100%;background-color: #f8f8f8} form input{ outline: none; font-family: 微软雅黑; font-size: 16px; transition: all .5s ease; } form input:focus { border-color: rgba(82, 168, 236, 0.8); outline: thin dotted \9; box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6); } p{text-align: center;padding: 10 0 0 0;} .query_phone{ width: 90%; height: 40px; padding-left: 5%;/*设置placeholder的位置*/ } .submit{ width: 90%; height: 50px; color: #fff; font-size: 16px; background-color: rgb(97,178,220); transition: all .5s ease; font-family: 微软雅黑; } .submit:hover{ background-color: rgb(97,178,255); } /*input placeholder样式*/ :-moz-placeholder { /* Mozilla Firefox 4 to 18 */ opacity:.5; } ::-moz-placeholder { /* Mozilla Firefox 19+ */ opacity:.5; } input:-ms-input-placeholder{ opacity:.5; } input::-webkit-input-placeholder{ opacity:.5; } input::-webkit-input-placeholder { /* WebKit browsers*/ } input:-moz-placeholder { /* Mozilla Firefox 4 to 18*/ } input::-moz-placeholder { /* Mozilla Firefox 19+*/ } input:-ms-input-placeholder { /* Internet Explorer 10+*/ } </style> <script type="text/javascript"> function checkMobile(){ var sMobile = document.mobileform.phone.value.trim(); if(!(/^1[3|4|5|6|7|8|9][0-9]{5,9}$/.test(sMobile))){ alert("不是完整的11位手机号或者正确的手机号前七位"); document.mobileform.phone.focus(); return false; } } </script> </head> <body> <form class="phone_check_form" name="mobileform" method="get" action="query_phone.php" onsubmit="return checkMobile()";> <p><input class="query_phone" name="phone" type="text"/ required="" placeholder="13414503051" maxlength="11"></p> <p><input class="submit" name="submit" type="submit" value="查询"/></p> <p align="center" style="font-size: 12px;margin-top: 50px;">by Vegeta</p> </form> </body> </html>
query_phone.php
<meta charset="utf-8"> <?php header("Content-type:text/html,charset=utf8"); include('simple_html_dom.php'); function query($phone='') { $url='http://www.ip138.com:8080/search.asp?action=mobile&mobile='.$phone; $ch = curl_init(); $timeout = 5; curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt ($ch, CURLOPT_REFERER, 'http://www.cltt.org/studentscore'); $contents = curl_exec($ch); $contents = mb_convert_encoding($contents, 'utf-8', 'GBK,gb18030,gb2312'); curl_close($ch); return $contents; } function simple($phone='') { $contents = query($phone); $html = new simple_html_dom(); $html ->load($contents); $arrMsg = array(); foreach($html->find('table tbody tr td') as $m) { array_push($arrMsg,$m->plaintext); } return $arrMsg; } $ph=$_GET["phone"]; var_dump(simple($ph)); ?>
simple_html_dom.php
需要下载php解析html类库:simple_html_dom.php
2、效果截图
相关推荐:
PHP手机号码归属地查询代码(API接口/mysql)_PHP教程
The above is the detailed content of PHP's cURL implements mobile phone number location query function. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The reasons why the mobile phone number is empty: 1. The mobile phone number has been blacklisted by the other party; 2. The other party has set up the call transfer function, and the transferred number is an unconventional mobile phone number range, such as 11 digits pressed randomly; 3. The number is wrong ; 4. Virtual number; 5. The number has been canceled and is in the recovery freezing period; 6. The operator's system failure will cause the user's mobile phone to have an empty number in a regional and range manner; 7. The signal is not good; 8. The number The format is wrong; 9. Mobile phone card failure; 10. Special ringtone.

I don’t know if you have such an experience. Your mobile phone often receives some inexplicable text messages, or registration information for some websites or other verification information. In fact, our mobile phone number may be bound to many unfamiliar websites, and we ourselves Even if you don’t know, what I will share with you today is to teach you how to unbind all unfamiliar websites with one click. Step 1: Open the number service platform. This technique is very practical. The steps are as follows: Open WeChat, click the plus icon in the search box, select Add Friend, and then enter the code number service platform to search. We can see that there is a number service platform. Of course, it belongs to a public institution and was launched by the National Institute of Information and Communications Technology. It can help everyone unbind mobile phone number information with one click. Step 2: Check whether the phone has been marked for me

Both curl and Pythonrequests are powerful tools for sending HTTP requests. While curl is a command-line tool that allows you to send requests directly from the terminal, Python's requests library provides a more programmatic way to send requests from Python code. The basic syntax for converting curl to Pythonrequestscurl command is as follows: curl[OPTIONS]URL When converting curl command to Python request, we need to convert the options and URL into Python code. Here is an example curlPOST command: curl-XPOST https://example.com/api

Amap is loved by users for its precise positioning and rich functions. However, during use, sometimes we may need to change the bound mobile phone number to ensure the accuracy of personal information and services. So, how to change the mobile phone number of Amap? The editor has compiled some relevant information, come and take a look with me! How to change the mobile phone number on Amap? Answer: [Amap]-[My]-[Settings Icon]-[Account and Security]-[Mobile Number]-[Change]-[Next Step]. Specific steps: 1. First open the Amap software and enter the home page. We need to click [My] in the lower right corner; 2. Then you can see some related functions in My One Second. Here we click on the upper right corner. [Settings icon] in the corner;

To update the curl version under Linux, you can follow the steps below: Check the current curl version: First, you need to determine the curl version installed in the current system. Open a terminal and execute the following command: curl --version This command will display the current curl version information. Confirm available curl version: Before updating curl, you need to confirm the latest version available. You can visit curl's official website (curl.haxx.se) or related software sources to find the latest version of curl. Download the curl source code: Using curl or a browser, download the source code file for the curl version of your choice (usually .tar.gz or .tar.bz2

From start to finish: How to use php extension cURL for HTTP requests Introduction: In web development, it is often necessary to communicate with third-party APIs or other remote servers. Using cURL to make HTTP requests is a common and powerful way. This article will introduce how to use PHP to extend cURL to perform HTTP requests, and provide some practical code examples. 1. Preparation First, make sure that php has the cURL extension installed. You can execute php-m|grepcurl on the command line to check

PHP8.1 released: Introducing curl for concurrent processing of multiple requests. Recently, PHP officially released the latest version of PHP8.1, which introduced an important feature: curl for concurrent processing of multiple requests. This new feature provides developers with a more efficient and flexible way to handle multiple HTTP requests, greatly improving performance and user experience. In previous versions, handling multiple requests often required creating multiple curl resources and using loops to send and receive data respectively. Although this method can achieve the purpose

With the continuous advancement of mobile communication technology, mobile phone numbers have become an indispensable communication tool in our daily lives. Sometimes, we need to check the usage status of a mobile phone number, such as verifying whether the number is out of service or in arrears. 1. How to check the usage status of mobile phone number? Contacting the operator's customer service is the most direct way to check the usage status of your mobile phone number. Different operators may have different inquiry methods, but this can usually be accomplished by calling the operator's customer service hotline. When talking to customer service staff, you only need to provide the mobile phone number you need to query, and the customer service staff will provide you with detailed usage status information. Therefore, if you want to know the specific situation of a certain mobile phone number, you can get relevant information by calling the operator's customer service hotline. There are
