- 精华
- 0
- 帖子
- 142
- 威望
- 0 点
- 积分
- 142 点
- 种子
- 5 点
- 注册时间
- 2016-7-8
- 最后登录
- 2024-8-27
|
发表于 2017-3-15 23:08 · 湖北
|
显示全部楼层
本帖最后由 ryukinkou 于 2017-3-15 23:10 编辑
看你们刷的这么幸苦,给你们个脚本吧监控官网的,自动刷到邮件通知你们.
还有监控amazon的,就不发了。
要安装python3,然后pip3 install bs4.**这个是t i m e,居然连这个都屏蔽。
- # coding=utf-8
- import **
- import urllib.request as request
- from bs4 import BeautifulSoup
- import smtplib
- from email.mime.text import MIMEText
- import random
- check_1 = False
- check_2 = False
- url = 'https://store.nintendo.co.jp/category/NINTENDOSWITCH/HAC_S_KAYAA.html'
- while True:
- try:
- page = request.urlopen(url).read()
- soup = BeautifulSoup(page, "html.parser")
- except Exception as err:
- print(err)
- **.sleep(random.randint(0, 5))
- continue
- for p in soup.find_all('p', attrs={'class': 'zaiko'}):
- for span in p.find_all('span'):
- if str.strip(span.text) == '在庫×':
- check_1 = True
- break
- if check_1:
- break
- for p in soup.find_all('p', attrs={'class': 'nosale'}):
- if str.strip(p.text) == 'SOLD OUT':
- check_2 = True
- break
- if check_1 and check_2:
- print('sold out')
- else:
- msg = MIMEText(url, _subtype='plain', _charset='utf-8')
- msg['Subject'] = 'ゲットだぜ'
- msg['From'] = '<mail>@163.com'
- msg['To'] = '<mail>@163.com'
- try:
- server = smtplib.SMTP()
- server.connect('smtp.163.com')
- server.login('<username>', '<password>')
- server.sendmail(msg['From'], msg['To'], msg.as_string())
- server.close()
- except Exception as err:
- print(err)
- **.sleep(random.randint(0, 5))
- continue
- print('ゲットだぜ NS at Nintendo Official Site')
- break
- **.sleep(random.randint(20, 30))
复制代码
|
|