本帖最后由 beng 于 2019-11-29 17:06 编辑
功能:
1.按个人要求筛选匹配条件[修改settings即可]
2.声音提醒功能
3.自动生成购物车链接
4.无第三方库,是python就能跑
等等再写个Selenium+chrome的脚本 全自动
- import requests
- import json
- import re
- import time
- import sys
- import winsound
- settings = {
- 'price': 15,
- 'virt': 'KVM',
- 'ram': 2048,
- 'cpu': 2,
- 'hdd': 30,
- 'bw': 1500,
- 'ips': 1,
- }
- url = 'https://billing.virmach.com/modules/addons/blackfriday/new_plan.json'
- def run():
- response = json.loads(requests.get(url).text)
- price = response['price']
- if 'yr' in price:
- price = float(re.findall('\$(.+?) <span>/yr</span>', price)[0])
- virt = response['virt']
- ram = int(response['ram'])
- cpu = int(response['cpu'])
- hdd = int(response['hdd'])
- bw = int(response['bw'])
- ips = int(response['ips'])
- pid = response['pid']
- location = response['location'] # BUFFALO
- if price <= settings['price'] and virt == settings['virt'] and ram >= settings['ram'] and cpu >= settings[
- 'cpu'] and hdd >= settings['hdd'] and bw >= settings['bw'] and ips >= settings['ips']:
- winsound.Beep(500, 1000)
- print(price)
- print(cpu, 'H', ram, 'M', bw, 'G')
- print('hdd:', hdd, 'G')
- if ips > 1:
- print(ips)
- print(location)
- print('https://billing.virmach.com/cart.php?a=add&pid=' + str(pid))
- else:
- item = '无符合机器 ' + time.strftime("%H:%M:%S %Y-%m-%d", time.localtime())
- sys.stdout.write('\r' + str(item) + '\033[K')
- sys.stdout.flush()
- while 1:
- run()
- time.sleep(5)
复制代码 |