Skip to content

Instantly share code, notes, and snippets.

@Wybxc
Created August 30, 2023 06:49
Show Gist options
  • Select an option

  • Save Wybxc/68cfb28ec1b91ac6ee2cab190006b150 to your computer and use it in GitHub Desktop.

Select an option

Save Wybxc/68cfb28ec1b91ac6ee2cab190006b150 to your computer and use it in GitHub Desktop.
connect to pku its
# -*- 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