标签:chap json xxxxxx int xxxxx word orm return import
# HttpRequest测试类
import requests class HttpRequest: def http_request(self, url, method, data=None, cookie=None): try: if method.upper() == "GET": res = requests.get(url, data, cookies=cookie) elif method.upper() == "POST": res = requests.post(url, data, cookies=cookie) else: print("请输入正确的参数") except Exception as e: print("请求报错了:{}".format(e)) raise e return res if __name__ == ‘__main__‘: # 登录 login_url = "http://v.rainbowred.com/login" login_data = {"username": "15546355872", "password": "xxxxxx", "rememberCheck": "1", "loginStatus": "1", "rememberStatus": "1", "autoLogin": "0", "language": "zh"} login_res = HttpRequest().http_request(login_url, "post", login_data) print(login_res.json()) # 选择公司 c_url = "http://v.rainbowred.com/chc" c_data = {"companyId": "21"} c_res = HttpRequest().http_request(c_url, "post", c_data, cookie=login_res.cookies) print(c_res.json())
标签:chap json xxxxxx int xxxxx word orm return import
原文地址:https://www.cnblogs.com/come202011/p/12230593.html