Skip to content

Instantly share code, notes, and snippets.

@rinh
Created May 12, 2023 04:21
Show Gist options
  • Save rinh/c803f7e874f579612681955e52f1571e to your computer and use it in GitHub Desktop.
Save rinh/c803f7e874f579612681955e52f1571e to your computer and use it in GitHub Desktop.
bjedu
import arrow
import asyncio
from pyppeteer import launch
from bs4 import BeautifulSoup
from pync import Notifier
import time
def parse_html(html_content):
soup = BeautifulSoup(html_content, features="lxml")
# print(html_content)
# print(soup.find("form.layui-form").text)
results = []
for i in soup.select('div.layui-table-body table td[data-field="time1"]'):
results.append(i.text.strip())
# 取出results前5个作为 re5
for i in results[:5]:
if "剩余" in i:
msg = "有啦有啦!!!赶紧去看!!!!"
Notifier.notify(msg, title='666')
time.sleep(3300000)
if "剩余" in ",".join(results[:-3]):
msg = "有啦有啦!!!赶紧去看!!!!"
Notifier.notify(msg, title='666')
time.sleep(3300000)
# msg = f"{arrow.now().format('YYYY-MM-DD HH:mm:ss')} 本轮没有!!!"
#
# Notifier.notify(msg, title='666')
async def main():
browser = await launch()
page = await browser.newPage()
url = "https://yjzc.bjedu.cn/regsvc/pflow/page?stepId=stu_info_subscribe_ajdd&page=subscribe/subscribe"
headers = {
"Cookie": ""
}
await page.setExtraHTTPHeaders(headers=headers)
await page.goto(url)
html = await page.content()
parse_html(html)
await browser.close()
if __name__ == '__main__':
while 1:
asyncio.get_event_loop().run_until_complete(main())
# 暂停1分钟
time.sleep(60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment