def api_fb_set(self, url): headers = {'Content-Type': 'application/json'} data = { "action": "set", "name": "homepage", "value": "{\"news\":[5],\"notice\":[1],\"paper\":[5]}" } session = GetSession().get_session() return session.post(url, json=data, headers=headers)
def api_upload(self, url): with open(BASE_PATH + os.sep + 'data' + os.sep + '我的头像.jpg', 'rb') as f: headers = { 'content-type': "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" } file = {'upload1': f} session = GetSession().get_session() return session.post(url, files=file)
def api_add_notice_post(self, url, title, content): headers = {'Content-Type': 'application/json'} data = { "action": "addone", "data": { "title": title, "content": content } } session = GetSession().get_session() return session.post(url, json=data, headers=headers)
def api_set_info(self, name, url): headers = {'Content-Type': 'application/json'} params = {"action": "getmyprofile"} session = GetSession().get_session() data = { "action": "setmyprofile", "newdata": { "realname": name, "password": "******" } } return session.post(url, json=data, params=params, headers=headers)
def api_add_account_post(self, url, realname, username, password, number, desc, type): headers = {'Content-Type': 'application/json'} data = { "action": "addone", "data": { "realname": realname, "username": username, "password": password, "studentno": number, "desc": desc, "usertype": type } } session = GetSession().get_session() return session.post(url, json=data, headers=headers)
def api_click(self, url): headers = {'Content-Type': 'application/json'} data = {"action": "thumbuporcancel", "paperid": 5} session = GetSession().get_session() return session.post(url, json=data, headers=headers)