Here we get the data from the data interface of Wanwang or Xinwang, and then output it through simple text processing in PHP.
Copy the code The code is as follows:
$domain = $_GET['q'];
preg_match("|
(.+?)
|is", @file_get_contents('//m.sbmmt.com/Modules/agent/serv/pages/domain_whois.jsp?domainNameWhois='.$domain.'&noCode=noCode'), $whois);
echo $whois[1];
?>
After reaching this point, some friends may ask, isn’t this just a simple php script? ! Which is the api interface? Then let’s process it to make the query method more professional:
The query format we need is as follows:
http://api/whois/baidu.com
where baidu.com is the domain name that needs to be queried
You can modify the nginx configuration to achieve this:
Copy code The code is as follows:
location ~* /whois/(.+)$ {
proxy_pass http://127.0.0.1:8080/whois/index.php?q=baidu .com
# Pass the query to the apache of the intranet for processing
}
ok. Now a whois api interface is completed. You can call it in your own program or share it with everyone ^_^!