微信域名拦截检测

微信域名拦截采用云拦截的机制, 那么如果检测一个域名是否被拦截那?

1. 第一步:浏览器打开地址: https://wx.qq.com/ 登录网页微信

2. 打开浏览器调试模式, 一般为F12, 找到:

找到Cookie 和User-agnet

 

3. 代码 用第二部的参数替换代码中的cookie, useragent 测试:

    public boolean isBlock(String domain, String userAgent, String cookie){
        HttpURLConnection connection = null;
        InputStream is = null;
        BufferedReader br = null;
        String result = null;
        try {
            URL url = new URL(MessageFormat.format("https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxcheckurl?requrl={0}", URLEncoder.encode(domain, "utf-8")));
            connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            // !!!!!! 这里是最重要的
            connection.setRequestProperty("User-Agent", userAgent);
            connection.setRequestProperty("Cookie", cookie);
            connection.connect();

            if (connection.getResponseCode() == 200) {
                is = connection.getInputStream();
                br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
                StringBuffer sbf = new StringBuffer();
                String temp = null;
                while ((temp = br.readLine()) != null) {
                    sbf.append(temp);
                    sbf.append("\r\n");
                }
                result = sbf.toString();
            }
        }catch (Exception e){
            System.out.println(e);
        }
        System.out.println(result);
        if(result.contains("\"retcode\":0")){
            return  true;
        }else{
            return false;
        }

    }

    public static void main(String args[]) throws Exception{
        // 合法域名 https://www.baidu.com
        // 非法域名 http://airav.cc
        boolean block = new DomainController().isBlock("https://www.baidu.com",
                "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36",
                "xxxxxxxxxxxxxxxxxxxxxxxx");
        System.out.println(block);

//        boolean block = new DomainController().isBlock("http://airav.cc",
//                "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36",
//                "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
//        System.out.println(block);

    }

4. 个人封装接口:

5. 备注: 2019-07-26 亲自测试有效。另外网上有很多收费的版本,但是稳定性可能不高, 所谓道高一尺,魔高一丈。腾讯会不断的升级自己的策略。

微信交流:13257734257

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值