background
Due to the stricter restrictions, domain names are judged to be induced sharing. Therefore, the company decided to investigate a set of stable, fast and accurate detection and query interfaces for the domain name interception.
The development group tried to search for a period of time, and found that the source code and principles were rarely shared. Then we groped for a few days and finally solved the problem.
The domain name detection interface is from:
principle
Use Wireshark grab to get the domain name interception query interface.
Domain names have the following states:
- Domain name can be accessed normally (not blocked).
- Domain name is intercepted
- The non official website will continue to be translated into the mobile preview mode (adding the domain name to the business domain name in the background of the public address can usually solve this problem).
- According to user complaints and Tencent security website security center detection, the web page contains malicious fraud content, and has stopped visiting to maintain the green Internet environment.
- Web pages contain induced sharing, attention and other induced behavior content, which has been complained by many people. In order to maintain a green online environment, visits have been stopped.
Demo
PHP version
<?php // Your API Token is available in the User Center. $apiToken = "********************************"; // Address or domain name to be detected $reqUrl = "www.qq.com"; $url = sprintf("https://wx.horocn.com/api/v1/wxUrlCheck?api_token=%s&req_url=%s", $apiToken, $reqUrl); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); $responseBody = curl_exec($ch); $responseArr = json_decode($responseBody, true); if (json_last_error() != JSON_ERROR_NONE) { echo "JSON Error parsing interface result\n"; return; } if (isset($responseArr['code']) && $responseArr['code'] == 0) { // Interface returned correctly // Value range of $responseArr['data']['status']: ok, blocked // ok means normal, blocked means blocked printf("Test address(%s)The state is:%s\n", $reqUrl, $responseArr['data']['status']); } else { printf("Interface exception:%s\n", var_export($responseArr, true)); }
Python version
# -*- coding: utf-8 -*- import json, urllib from urllib import urlencode def main(): # Your API Token is available in the User Center. apiToken = "*********************" url = "https://wx.horocn.com/api/v1/wxUrlCheck" params = { "req_url" : "www.qq.com", #Address or domain name to be detected "api_token" : apiToken, } params = urlencode(params) f = urllib.urlopen("%s?%s" % (url, params)) content = f.read() res = json.loads(content) if res: code = res["code"] if code == 0: #Successful request print res["result"] else: print "%s: %s" % (res["code"],res["msg"]) else: print "request api error" if __name__ == '__main__': main()