177-371-24501(同微信)

头脑王者辅助工具开发的实战教程

2022-04-21 管理员

 

最近直播答题火热,群里也经常看到比拼微信小程序《头脑王者》。我比较笨,凭纯答题只到了黑金段位。鉴于本周刚刚点亮了收集抓包的技能,于是想试着通过这个来做一个辅助工具。

抓包

我使用的是fiddler抓的,网上关于抓app包的教程很多,可自行查阅,这里不赘述。根据抓包发现出题目的接口:

数据格式是一个 json 字符串,如下所示:

{"data":{"quiz":"我国的根本大法指的是?","options":["刑事诉讼法","刑法","婚姻法","宪法"],"num":3,"school":"理科","type":"地理","typeID":9,"contributor":"孙悦悦","partner":0,"endTime":1516447448,"curTime":1516447433,"myBuff":{}},"errcode":0}

解决了题目的获取,接下来就是想办法把题目传递到其他程序,利用FiddlerScript就可以了:

点击FiddlerScript然后选择OnbeforeResponse进入该函数内,写下如下代码:

这部分就是将题目发到自己写的一个程序上:

if (oSession.fullUrl.Contains("question.hortor.net/question/bat/findQuiz"))
{
    //把内容通过ajax http发送其它地方
    var _xhr = new ActiveXObject('Microsoft.XMLHTTP');
    var url = 'https://localhost:8000/api/brain_king/';

    //不需要返回值所以设置为空回调
    _xhr.onreadystatechange = function() {}
    _xhr.open('POST', url, true);
    _xhr.setRequestHeader("Content-Type", "application/json");
    _xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
    _xhr.send(oSession.GetResponseBodyAsString());
}

解答问题

得到问题后如何答题就见仁见智了,最简单的一个方式就是把问题提交到百度上,进行词频统计,大多数情况下词频多的为正确答案,于是我及其简单的做了处理:

class BrainKing(generics.GenericAPIView):
    def post(self, request):
        question_dict = request.data.get("data")
        question_text = question_dict["quiz"]
        choices = question_dict["options"]
        content = session.get('https://www.baidu.com/s?wd=' + question_text, timeout=2).text
        for choice in choices:
            print(choice + " : " + content.count(choice))
        return Response("")

成果展示

用这个上分确实很快,不过缺点也是比较明显的,带一些干扰词就不行了,但总体上王者还是比较轻松的:

我有个朋友真的靠纯答题上的王者,令人敬佩。最后提醒一下,游戏而已,不要为了攀比伤了和气。

 

小程序工具提供多类型商城/门店小程序制作,可视化编辑 1秒生成5步上线。通过拖拽、拼接模块布局小程序商城页面,所看即所得,只需要美工就能做出精美商城。

更多微信小程序相关资讯,请前往:https://www.kesion.com/miniprogramschool/

<style type="text/css"> .appreciate{ margin-bottom:16px;} .appreciate .btn_appreciation { display: block; width: 110px; height: 40px; margin: 40px auto 0;font-size: 18px; line-height: 40px; text-align: center; vertical-align: middle; color: #fff; border-radius: 5px; background: #ff8000;} .appreciate .head_count.show { display: block;} .appreciate .head_count {display: none; margin: 30px auto 0; font-size: 14px;text-align: center;} .appreciate .head_count i {color: #ff8000;} .appreciate .head_count b {color: gray;} .appreciate_list_wrapper{ overflow: hidden; margin: 0 auto; width: 200px;} .appreciate_list.vcenter{ text-align: center;} .appreciate_list.vcenter a{ display:block;} .appreciate_list { max-height: 120px; overflow: hidden; margin-right: -6px; line-height: 15px;} .appreciate_list img { position: relative; width: 34px; height: 34px; margin: 0 6px 4px 0; border-radius: 17px;max-width: 100%!important;} .appreciate .btn_appreciation_t{background: #dc5d4a;} .appreciate .head_count_t i {color: #607fa6;} .appreciate_list_wrapper_t{ overflow: hidden; margin: 0 auto; width: 250px;} .appreciate_list_t.vcenter_t { text-align: center;} .appreciate_list_t.vcenter_t a{ display:block;} .appreciate_list_t { max-height: 120px; overflow: hidden; margin-right: -6px; line-height: 15px;} .appreciate_list_t img { position: relative; width: 30px; height: 30px; margin: 0 6px 4px 0;max-width: 100%!important;}</style>
上一篇:微信小程序开发:简单配置教程
下一篇:类似头脑王者小程序开发,头脑王者小程序怎么开发
相关资讯 Releva ntnews
解决方案 Solutions
相关热点 Hot spot
快速提升网站排名的方法
  1. 我们的优势
  2. 我们的实力
  3. 选择我们的理由
咨询电话(微信同号)

177-371-24501(同微信)

豫ICP备17049932号

Copyright © 2017-2022 版权所有 追风建站 Rights Reserved 技术支持:酷微科技

电话咨询 在线咨询 服务项目 SEO优化