Last active
January 31, 2021 14:22
-
-
Save MrAru/a84408d3381414f20f68aa27867def36 to your computer and use it in GitHub Desktop.
Javascript file to automatically complete Daily Health in XMU
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { chromium } = require('playwright'); | |
| (async () => { | |
| const COOKIES = [{ | |
| name: '_dx_captcha_vid', | |
| value: '', // Enter your "_dx_captcha_vid" value here | |
| url: 'https://xmuxg.xmu.edu.cn/app/214' | |
| }, { | |
| name: 'SAAS_U', | |
| value: '', // Enter your "SAAS_U" value here | |
| url: 'https://xmuxg.xmu.edu.cn/app/214' | |
| }, { | |
| name: 'SAAS_S_ID', | |
| value: '', // Enter your "SAAS_S_ID" value here | |
| url: 'https://xmuxg.xmu.edu.cn/app/214' | |
| }]; | |
| const XPATH = { | |
| form: 'xpath=//html/body/div[1]/div/div/div/div/div[1]/div[2]/div/div[3]/div[2]', | |
| selector: 'xpath=//html/body/div[1]/div/div/div/div/div[2]/div[1]/div/div/div[3]/div/div[22]/div/div/div', | |
| label: 'xpath=//html/body/div[8]/ul/div/div[3]/li/label', | |
| save: 'xpath=//html/body/div[1]/div/div/div/div/div[2]/div[1]/div/div/span/span' | |
| }; | |
| const browser = await chromium.launch({ headless: false }); | |
| const page = await browser.newPage(); | |
| await page.context().addCookies(COOKIES); | |
| await page.goto('https://xmuxg.xmu.edu.cn/app/214'); | |
| page.on('dialog', async dialog => { | |
| await dialog.accept(); | |
| }); | |
| await page.click(XPATH.form); | |
| await page.click(XPATH.selector); | |
| await page.click(XPATH.label); | |
| await page.click(XPATH.save); | |
| await new Promise(r => setTimeout(r, 5000)); | |
| await browser.close(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment