最近汽车置换省补改成抢券了,顺手写了一个nodejs抢券代码

该文章已生成可运行项目,

抢券的首页有一个网页版本,根据控制台看到了,列表的请求,于是复制拿到nodejs写了一下

在这里插入图片描述

//需要安装的依赖
npm install node-notifier axios
//抢券代码
import axios from 'axios';
import notifier from 'node-notifier';
import path from 'path';
const area = '河北' //改成你的省份
const city = "保定" //改成你的城市
async function fetchData() {
  try {
    const response = await axios.get('https://api.dcarapi.com/motor/dealer_activity/gov_v2/activity_list', {
      params: {
        __method: 'window.fetch',
        city_name: city ,
        device_id: '1581562008988874',
        version_code: '867'
      },
      headers: {
        'accept': '*/*',
        'accept-language': 'zh-CN,zh;q=0.9',
        'cache-control': 'no-cache',
        'content-type': 'application/x-www-form-urlencoded',
        'pragma': 'no-cache',
        'priority': 'u=1, i',
        'sec-fetch-dest': 'empty',
        'sec-fetch-mode': 'cors',
        'sec-fetch-site': 'same-origin'
      },
      withCredentials: false
    });

    const resData = response.data.data;
    const hebeiItem = resData.tab_info.find(item => item.tab_name === area );
    const cityInfo = hebeiItem.activity_list.find(item => item.city_name === city );
    const flag = cityInfo.button_list.find(item => item.button_text === '去领取');
    console.log(Date.now(),flag)
    // 如果flag存在,则显示系统通知
    if (flag) {
      notifier.notify({
        title: '抢券提醒',
        message: '有可领取的优惠券了!',
        sound: true,
        wait: true
      });
      
      console.log('有可领取的优惠券了!');
    }

  } catch (error) {
    console.error('Error fetching data:', error.message);
  }
}

// 调用函数发起请求
setInterval(() => {
  fetchData();
}, 1000);

这功能只是监听有没有券,有券会给你消息弹窗,你去app上自己操作领取

在这里插入图片描述

本文章已经生成可运行项目
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

未脱发程序员

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值