Created
August 30, 2023 06:49
-
-
Save Wybxc/68cfb28ec1b91ac6ee2cab190006b150 to your computer and use it in GitHub Desktop.
connect to pku its
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
| # -*- coding: utf-8 -*- | |
| import requests | |
| from loguru import logger | |
| def connect() -> bool: | |
| logger.debug("开始连接") | |
| try: | |
| url = "https://its4.pku.edu.cn/cas/ITSClient" | |
| payload = { | |
| "username": "xxxxxxxx", | |
| "password": "xxxxxxxx", | |
| "iprange": "free", | |
| "cmd": "open" | |
| } | |
| headers = {"Content-type": "application/x-www-form-urlencoded"} | |
| result = requests.post(url, params=payload, headers=headers) | |
| logger.debug(f"连接成功: {result.text}") | |
| return True | |
| except Exception as e: | |
| logger.error(f"连接失败: {e}") | |
| return False | |
| connect() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment