Bandwagon Host / 搬瓦工 利用API自动切换机房脚本 | 萌咖

Bandwagon Host / 搬瓦工 利用API自动切换机房脚本

2018年11月12日 Vicer 7 1次 推荐给百度

最近萌咖购买了一个搬瓦工机器, 双十一特价款, 年付不到30美元,支持支付宝.
配备三网CN2线路能够自由的切换机房,切换IP地址!
填入优惠码 BWH26FXH3HIQ 即可享受-6.25%的循环优惠, 点击购买 数量有限.

  • 简介
  • 听说 DC8 机房好一点, 但是机房爆满.
    有没有足够的耐心去手动点击.
    好在搬瓦工提供了便利的API.
    利用API可以做很多事情.
    可以通过Linux自带的wget调用搬瓦工的API,实在是方便.

    需要在搬瓦工机器后台面板中找到 API.
    记录VEIDAPI KEY.然后将其填入脚本中.
    切换到目标机房后,将会自动停止.

  • 下载
  • 1
    wget --no-check-certificate -qO BWH.sh 'https://moeclub.org/attachment/LinuxShell/BWH.sh' && chmod a+x BWH.sh

  • 设置
  • 自行以下设置项:

    1
    2
    3
    4
    veid='1234560'; # VEID
    api_key='private_xxxxxxxxxxxxxxxxx'; # API KEY
    ToLocation='USCA_8'; # 目标机房代码.
    Timeout='150'; # API频率有限制,单位秒.每150秒运行一次.(不建议过低,否则面板报错.)

  • 运行
  • 1
    2
    3
    4
    #前台运行
    bash BWH.sh
    #后台运行
    nohup bash BWH.sh >/dev/null 2>&1 &

  • 预览
  • 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    #!/bin/bash
    veid='1234560';
    api_key='private_xxxxxxxxxxxxxxxxx';
    ToLocation='USCA_8';
    Timeout='150';
    # START
    [[ -n "$veid" ]] || exit 1
    [[ -n "$api_key" ]] || exit 1
    [[ -n "$ToLocation" ]] || exit 1
    [[ -n "$Timeout" ]] || exit 1
    CurrentLocation='';
    Token="?veid=${veid}&api_key=${api_key}";
    API_URL="https://api.64clouds.com/v1/";
    while [[ "$CurrentLocation" != "$ToLocation" ]]; do
    CurrentLocation=$(wget --no-check-certificate -qO- "${API_URL}migrate/getLocations${Token}" |grep -o '"currentLocation":"[^"]*"' |cut -d'"' -f4)
    echo "$(date +"[%Y/%m/%d %H:%M:%S]") ${CurrentLocation}";
    if [ -n "$CurrentLocation" -a "$CurrentLocation" != "$ToLocation" ]; then
    echo -n "${ToLocation}: "
    wget --no-check-certificate -qO- "${API_URL}migrate/start${Token}&location=${ToLocation}" |grep -o '"message":"[^"]*"' |cut -d'"' -f4
    else
    break;
    fi
    sleep ${Timeout};
    done

各种形式的转载请注明原文链接: Bandwagon Host / 搬瓦工 利用API自动切换机房脚本
  1. 匿名

    支持一下大佬

  2. thoughcn

    感谢亲爱的大佬。

  3. 韧体

    感谢大佬!

  4. 前排支持大佬

    PS 大佬的DD win脚本真香

  5. 设置的360秒刷一次,今早打开VPS被封了,网站也打不开,登录后台提示:API: too many requests in 24 hours, please try again later (700012),怎么才能解封!!

    1. Vicer作者

      只能等,或者工单客服.
      他家的API限制很严格,
      15分钟内不能超过多少次,24小时内不能超过多少次.

发表评论

电子邮件地址不会被公开。 必填项已用*标注

*
*
*


comments powered by Disqus