监测这个页面:https://www.szhdy.com/activities/default.html?method=activity&id=11
日本机还行,虽然我不买(联通和移动线路都是软银,是真的很软),但监控看看也行。
import requests
import json
from bs4 import BeautifulSoup
# ====== 配置区 ======
FEISHU_WEBHOOK_URL = "https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxx" # ← 替换为你自己的
MONITOR_URL = "https://www.szhdy.com/activities/default.html?method=activity&id=11"
# ===================
def send_feishu_message(text: str, title: str = "狐蒂云补货提醒"):
"""
通过飞书机器人发送
"""
try:
payload = {
"msg_type": "text",
"content": {
"text": title + '\n' + text
}
}
resp = requests.post(
FEISHU_WEBHOOK_URL,
data=json.dumps(payload),
headers={"Content-Type": "application/json; charset=utf-8"},
timeout=10
)
if resp.status_code == 200:
print("✅ 飞书通知发送成功!")
else:
print(f"❌ 飞书通知失败: {resp.text}")
except Exception as e:
print(f"❌ 发送飞书消息出错: {e}")
def check_japan_server_stock():
"""
检查日本云服务器(data-id=390)是否补货
"""
try:
response = requests.get(MONITOR_URL, timeout=10)
response.raise_for_status()
soup = BeautifulSoup(response.text, 'html.parser')
# 定位日本云服务器卡片
japan_card = soup.find('div', class_='cat-styleC-promotion-card', attrs={'data-id': '390'})
if not japan_card:
print("⚠️ 未找到日本云服务器(data-id=390)")
return False
buy_btn = japan_card.find('a', class_='form-footer-butt')
if not buy_btn:
print("⚠️ 未找到购买按钮")
return False
btn_classes = buy_btn.get('class', [])
btn_text = buy_btn.get_text(strip=True)
href = buy_btn.get('href', '')
# 售罄判断
if 'disableButton' in btn_classes:
print(f"⏳ 状态:{btn_text}(售罄)")
return False
else:
print(f"🎉 补货啦!按钮:'{btn_text}',链接:{href}")
return True
except Exception as e:
print(f"❌ 检查库存时出错: {e}")
return False
def main():
"""仅执行一次检查"""
print("🔍 正在检查日本云服务器库存状态(仅一次)...")
if check_japan_server_stock():
message = (
"日本云服务器已补货!\n"
f"活动页面:{MONITOR_URL}\n"
"请立即前往抢购!"
)
send_feishu_message(message)
print("🔔 检测到有货,已发送通知。")
else:
print("📭 未检测到补货。")
if __name__ == '__main__':
main()
正文结束