Home > Backend Development > PHP Tutorial > php whois query API production method

php whois query API production method

高洛峰
Release: 2023-03-01 10:48:01
Original
1905 people have browsed it

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 ^_^!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template