码迷,mamicode.com
首页 > 其他好文 > 详细

qq在线人数统计,计算腾讯分分彩

时间:2017-11-13 14:05:33      阅读:3146      评论:0      收藏:0      [点我收藏+]

标签:dir   ace   color   tostring   adl   报错   一个   https   equals   

一、接口

本统计结果与im.qq.com右上角显示的在线人数数据相同。

以下两个接口都可以使用,第一个返回JSON字符窜,第二个返回一个.dat的文件,下载后打开也是JSON字符串,官网使用的是https://cgi.im.qq.com/data/1min_city.dat 加了https协议,JAVA运行会报错去掉S正常运行。

http://cgi.im.qq.com/cgi-bin/minute_city

http://cgi.im.qq.com/data/1min_city.dat

这两个接口都是返回JSON格式的字符串,如下:

{"time":"2017-11-13 11:50:12","\u5176\u4ed6":33229,"\u6cb3\u5317\u7701":3133,"\u5c71\u897f\u7701":1060,"\u5185\u8499\u53e4":926,"\u6c5f\u82cf\u7701":5554,"\u5b89\u5fbd\u7701":1518,"\u5c71\u4e1c\u7701":3771,"\u8fbd\u5b81\u7701":1528,"\u5409\u6797\u7701":1042,"\u9ed1\u9f99\u6c5f\u7701":866,"\u6d59\u6c5f\u7701":3285,"\u6c5f\u897f\u7701":1670,"\u798f\u5efa\u7701":2190,"\u6e56\u5317\u7701":2331,"\u6e56\u5357\u7701":1918,"\u6cb3\u5357\u7701":3268,"\u5e7f\u4e1c\u7701":9228,"\u5e7f\u897f":2221,"\u6d77\u5357\u7701":230,"\u56db\u5ddd\u7701":3199,"\u8d35\u5dde\u7701":1261,"\u4e91\u5357\u7701":1448,"\u897f\u85cf":82,"\u9655\u897f\u7701":1445,"\u7518\u8083\u7701":857,"\u5b81\u590f":276,"\u9752\u6d77\u7701":204,"\u65b0\u7586":1131,"\u53f0\u6e7e\u7701":28,"\u5317\u4eac\u5e02":2314,"\u4e0a\u6d77\u5e02":2077,"\u5929\u6d25\u5e02":808,"\u91cd\u5e86\u5e02":1993,"\u9999\u6e2f":67,"\u6fb3\u95e8":9,"minute":[253830109,253828114,253829956,253833362,253831279,253829801,253833383,253826247,253825543,253829464,253826568,253831751,253829399,253830998,253825092,253828054,253826972,253832420,253829276,253831385,253831821,253826831,253827395,253830134,253827741,253827733,253830934,253826264,253825708,253828891,253827626,253830846,253832033,253832611,253830235,253829340,253828440,253829646,253830615,253829011,253825138,253832211,253826789,253829566,253829237,253826910,253832649,253831237,253825358,253827953,253828650,253832207,253829812,253831073,253828368,253832581,253833835,253825330,253833873,253825571]}

time是数据返回时间

unnicode是省份数据

最后的minute 返回60条数据供https://im.qq.com/online/flash/ht/fla_https.swf动态图使用,每秒取一个数

二、JAVA实现计算腾讯分分彩开奖结果

在开始写代码之前需要导入JSON相关的JAR包,点击链接即可下载JSON相关JAR包。

计算规则:在线人数253830109 拆分成2+5+3+8+3+0+1+0+9=31    取31的各位数1 作为万位,0109作为千百十个位,计算结果为10109

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;


public class Curl {
    private static int c1 = 0;
    private static int c2 = 0;
    public static void main(String[] args) throws InterruptedException {
        String s;
        while(true){
            s = new SimpleDateFormat("mmss").format(new Date());
            String a = s.substring(0,2);
            String b = s.substring(2, 4);
            int c = Integer.parseInt(a);
            //System.out.println(s);
            if(b.equals("13")){//腾讯官网会在每分钟的11s 或者12s或者13s的时候更新数据
                qqOlinePeople(c);
            }
            Thread.sleep(1000);
        }
    }
    public static void qqOlinePeople(int c){
        HttpURLConnection conn = null;
        try {
            //URL realUrl = new URL("http://cgi.im.qq.com/cgi-bin/minute_city");两个接口都可以使用
            URL realUrl = new URL("http://cgi.im.qq.com/data/1min_city.dat");
            conn = (HttpURLConnection) realUrl.openConnection();
            conn.setRequestMethod("GET");
            conn.setUseCaches(false);
            conn.setReadTimeout(8000);
            conn.setConnectTimeout(8000);
            conn.setInstanceFollowRedirects(false);
            conn.setRequestProperty("User-Agent","Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0");
            int code = conn.getResponseCode();
            if (code == 200) {
                InputStream is = conn.getInputStream();
                BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
                StringBuffer buffer = new StringBuffer();
                String line = "";
                while ((line = in.readLine()) != null){
                    buffer.append(line);
                }
                String result = buffer.toString(); 
                JSONObject jsonObject = JSONObject.fromObject(result);
                String s1 = jsonObject.get("time").toString();
                JSONArray array = jsonObject.getJSONArray("minute");
                String s = array.get(0).toString();
                int l = Integer.parseInt(s);
                int a[] = new int[9];
                int i = 0;
                int sum = 0; 
                if(c%2==0){
                    c2 = l;
                }else{
                    c1 = l;
                }
                int cha = 0;
                if(c%2==0){
                    cha = c2-c1;
                }else{
                    cha = c1-c2;
                }
                while(true){
                    a[i]=l%10;
                    sum=sum+a[i];
                    i++;
                    l = l/10;
                    if(l/10==0){
                        a[i]=l;
                        break;
                    }                
                }
                NumberFormat nf = NumberFormat.getNumberInstance();
                s = nf.format(Long.parseLong(s));
                System.out.println("开奖结果:"+sum%10+","+a[3]+","+a[2]+","+a[1]+","+a[0]);
                System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())+" "+s1+" "+s+" "+(cha>=0?"+"+cha:cha));
//                for(int i=0 ; i<array.size();i++){
//                    String s  = array.get(i).toString();
//                    System.out.println(s);
//                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    
    }
}

将项目打包成.jar 在控制台中运行

技术分享

三、结语

综合比较来看,腾讯分分彩这个计算结果跟开奖结果还是有差距的。

从www.77tj.org来看  http://www.77tj.org这个页面的统计结果跟我的计算结果是一样的,也是取返回结果数组的第一个值。他的标题是QQ在线统计,

http://www.77tj.org/tencent 标题是腾讯在线统计,这个页面的统计结果用来计算的话就是正常的开奖结果。暂时找不到他们统计的接口,希望有能力的道友提供一下。

因为家人最近迷上了分分彩,所以想统计一下开奖结果,然后模拟一下投注和返奖,根据统计结果,然后点醒她。

 

有没有人知道另一个人数统计页面的接口啊。。。

qq在线人数统计,计算腾讯分分彩

标签:dir   ace   color   tostring   adl   报错   一个   https   equals   

原文地址:http://www.cnblogs.com/CryOnMyShoulder/p/7825721.html

(0)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!