侧边栏壁纸
博主头像
王旭阳个人博客博主等级

工欲善其事,必先利其器

  • 累计撰写 120 篇文章
  • 累计创建 28 个标签
  • 累计收到 23 条评论

目 录CONTENT

文章目录

微信域名拦截检测

wxy
wxy
2024-02-01 / 1 评论 / 2 点赞 / 295 阅读 / 4571 字
温馨提示:
本文最后更新于 2024-02-02,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

摘要

微信域名检测接口,最新官方接口检测域名在微信中打开是否被封被拦截。

为什么需要这个接口?因为在微信中推广链接,会涉及到违规,一旦链接违规,就会被微信封禁,禁止跳转,停止访问。
这个接口可以获取到你的链接的封禁情况,你可以开发实时监控系统,或者是嵌套多层跳转,精准监控每个域名的状态,实时监控推广情况,保证最佳的推广效果!

域名在微信被拦截的3种常见情况

1、域名因违规或有风险被拦截

2、类似 douyin.com 这种的竞争式拦截

3、有一个中间页的拦截,需要多次点击按钮才可以跳转到你的域名的,多是一些使用频次较低的域名后缀,例如 .xyz .link .top 后缀,这种情况,备案后向微信申诉即可解决

2024-02-01-gfjtiyeb.png

程序

python代码

import json
import urllib.parse
import urllib.request


def check_url(url):
    # 获取Url
    if url:
        # 调用官方接口
        check_url = 'https://cgi.urlsec.qq.com/index.php?m=url&a=validUrl&url=' + urllib.parse.quote(url)
        with urllib.request.urlopen(check_url) as response:
            data_msg = json.loads(response.read().decode('utf-8'))['data']
            if data_msg == 'ok':
                # 域名被封
                result = {
                    'code': 202,
                    'msg': '域名被封'
                }
            else:
                # 域名正常
                result = {
                    'code': 200,
                    'msg': data_msg
                }
    else:
        # 参数为空
        result = {
            'code': 202,
            'msg': '请传入Url'
        }

    # 输出JSON
    print(json.dumps(result, indent=4, ensure_ascii=False))


if __name__ == "__main__":
    # 替换为你要检测的URL
    target_url = 'https://baidu.com'
    check_url(target_url)

golang

package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"net/url"
)

func checkURL(url string) {
	if url != "" {
		// 调用官方接口
		checkURL := "https://cgi.urlsec.qq.com/index.php?m=url&a=validUrl&url=" + url
		response, err := http.Get(checkURL)
		if err != nil {
			fmt.Println(err)
			return
		}
		defer response.Body.Close()

		var data map[string]interface{}
		if err := json.NewDecoder(response.Body).Decode(&data); err != nil {
			fmt.Println(err)
			return
		}

		dataMsg, ok := data["data"].(string)
		if !ok {
			fmt.Println("无法解析响应数据")
			return
		}

		if dataMsg == "ok" {
			// 域名被封
			result := map[string]interface{}{
				"code": 202,
				"msg":  "域名被封",
			}
			outputJSON(result)
		} else {
			// 域名正常
			result := map[string]interface{}{
				"code": 200,
				"msg":  dataMsg,
			}
			outputJSON(result)
		}
	} else {
		// 参数为空
		result := map[string]interface{}{
			"code": 202,
			"msg":  "请传入Url",
		}
		outputJSON(result)
	}
}

func outputJSON(result map[string]interface{}) {
	// 输出JSON
	jsonData, err := json.MarshalIndent(result, "", "    ")
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(string(jsonData))
}

func main() {
	// 替换为你要检测的URL
	targetURL := "https://example.com"
	checkURL(targetURL)
}

来源

git:[@github/likeyun/liKeYun_WeChatDomainNameCheck]
2

评论区