From 12c82847672d87e7ce3e5848d4f33e304f1d86f9 Mon Sep 17 00:00:00 2001 From: david-ajax Date: Thu, 21 Apr 2022 01:51:37 +0800 Subject: [PATCH] Add pause.cpp --- README.md | 2 ++ juan/creater.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ juan/data.txt | 1 + juan/geckodriver.log | 0 juan/reader.py | 10 ++++++++++ onefile/README.md | 2 +- onefile/pause.cpp | 12 ++++++++++++ 7 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 juan/creater.py create mode 100644 juan/data.txt create mode 100644 juan/geckodriver.log create mode 100644 juan/reader.py create mode 100644 onefile/pause.cpp diff --git a/README.md b/README.md index 4080b0e..1c8424d 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,9 @@ |LAN++|./lanpp|一个跨平台的简易局域网文件传输工具|Python| |Plane Fighting|./plane_fighting|一个跨平台的简易"飞机大战"小游戏|Python| |Python HTTPS Server|./python_https_server|一个 HTTPS 网络服务器程序|Python| +|Juan|./juan|获取 http://www.zxx.edu.cn 的公开的用户学习数据并制作成图表, 看看人们有多卷|Python| ### 单文件 (onefile) |文件名|介绍|语言| |----|----|----| |file_reader.cpp|输出文件内容至终端|C++| +|pause.cpp|按任意键继续|C++| diff --git a/juan/creater.py b/juan/creater.py new file mode 100644 index 0000000..af0e420 --- /dev/null +++ b/juan/creater.py @@ -0,0 +1,44 @@ +from playwright.sync_api import Playwright, sync_playwright, expect +import bs4, time, datetime + +def addtofile(path, data): + with open(path, 'a', encoding='UTF-8') as f: + f.write(data) + f.close() + +def access(playwright: Playwright) -> None: + browser = playwright.chromium.launch(headless=True) + context = browser.new_context() + # Open new page + while True: + print("Exploring") + page = context.new_page() + # Go to https://www.zxx.edu.cn/ + page.goto("https://www.zxx.edu.cn/") + page.wait_for_load_state('networkidle') + html = page.content() + # Close page + page.close() + # --------------------- + context.close() + browser.close() + soup = bs4.BeautifulSoup(html, 'html.parser') + text = soup.text + p_f = text.index("做眼保健操今天已有") + p_e = text.index("人与你一起学习") + t_f = text.index("你们共浏览了") + t_e = text.index("次。主办") + person = text[p_f+9:p_e] + person = int(person.replace(",","")) + times = text[t_f+6:t_e] + times = int(times.replace(",","")) + print("Person: " + str(person)) + print("Times: " + str(times)) + total = [person, times, datetime.datetime.now().strftime('%Y-%m-%d')] + addtofile("data.txt",str(total) + "\n") + print("Data added completed") + time.sleep(300) + + +with sync_playwright() as playwright: + access(playwright) diff --git a/juan/data.txt b/juan/data.txt new file mode 100644 index 0000000..069f539 --- /dev/null +++ b/juan/data.txt @@ -0,0 +1 @@ +[22821, 105404, '2022-04-20'] diff --git a/juan/geckodriver.log b/juan/geckodriver.log new file mode 100644 index 0000000..e69de29 diff --git a/juan/reader.py b/juan/reader.py new file mode 100644 index 0000000..698036f --- /dev/null +++ b/juan/reader.py @@ -0,0 +1,10 @@ +import numpy as np +import matplotlib.pyplot as plt +f = open("data.txt", "r") +a = 0 +while a == 0: + f.readline + x = np.linspace(10., 100., 50) + y = x**10 + x**5 + x**2 + 100 + plt.plot(x, y) + plt.show() \ No newline at end of file diff --git a/onefile/README.md b/onefile/README.md index 62c0f7b..f3e415d 100644 --- a/onefile/README.md +++ b/onefile/README.md @@ -6,4 +6,4 @@ 请分别根据注释运行 ## 协议 详见文件内部注释 -如无注释, 根据 GPL 3.0 协议开源 +如无注释, 根据 GPL 3.0 协议开源 \ No newline at end of file diff --git a/onefile/pause.cpp b/onefile/pause.cpp new file mode 100644 index 0000000..a5a56ee --- /dev/null +++ b/onefile/pause.cpp @@ -0,0 +1,12 @@ +// pause.cpp +// LICENSE: Nothing(do what ever you want!) +#include +using namespace std; + +int main(){ + cout << "Press any key to continue..."; + cin.clear(); + cin.sync(); + cin.get(); + return 0; +}