最近购买了一个搬瓦工机器, 双十一特价款, 年付不到30美元,支持支付宝.
配备三网CN2线路能够自由的切换机房,切换IP地址!
填入优惠码 BWH26FXH3HIQ 即可享受-6.25%的循环优惠, 点击购买 数量有限.
博主目前没有切换,放上演示站:https://bwh.cvps.top
简介
听说 DC8 机房好一点, 但是机房爆满.
有没有足够的耐心去手动点击.
好在搬瓦工提供了便利的API.
利用API可以做很多事情.
可以通过Linux自带的wget调用搬瓦工的API,实在是方便.
需要在搬瓦工机器后台面板中找到 API.
记录VEID和API KEY.然后将其填入脚本中.
切换到目标机房后,将会自动停止.
下载脚本
wget --no-check-certificate -qO BWH.sh 'https://moeclub.org/attachment/LinuxShell/BWH.sh' && chmod a+x BWH.sh
设置
自行以下设置项:
veid='1234560'; # VEID api_key='private_xxxxxxxxxxxxxxxxx'; # API KEY ToLocation='USCA_8'; # 目标机房代码. Timeout='150'; # API频率有限制,单位秒.每150秒运行一次.(不建议过低,否则面板报错.)
运行
#前台运行 bash BWH.sh #后台运行 nohup bash BWH.sh >/dev/null 2>&1 &
脚本预览
[s][p]
#!/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
[/p]
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END








暂无评论内容