PHP Curl to achieve mobile phone number attribution to the query function

Source: Internet
Author: User
This article mainly and everyone to share the PHP curl to achieve mobile phone number attribution query function, hope to help everyone.

1, the code is as follows:

Index.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

Need to download PHP parsing HTML class library: simple_html_dom.php

2. Effect



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.