标签:agent strong ams htm roi table store import tty
依赖:
pip install requests
#coding=utf8 import requests # from common.logger import Logger # import logging class httpUtils: # logger = Logger("../logs/http.log",logging.INFO,logging.INFO) def get(self,url,params={},headers={}): res = requests.get(url,data=params,headers=headers) print("请求路径:" + res.request.url) headerStr = "" for headerKey in res.request.headers: headerStr = headerStr + "\n" + headerKey + ":" + res.request.headers[headerKey] print("请求头信息:" + headerStr) print("请求参数:\n" + res.request.body) resHeaderStr = "" for resHeaderKey in res.headers: resHeaderStr = resHeaderStr + "\n" + resHeaderKey + ":" + res.headers[resHeaderKey] print("响应头信息:" + resHeaderStr) print("返回结果:\n" + res.content.decode("utf-8")) return res def post(self,url,params={},headers={}): res = requests.post(url,data=params,headers=headers) print("请求路径:"+res.request.url) headerStr = "" for headerKey in res.request.headers: headerStr =headerStr+ "\n" + headerKey + ":" + res.request.headers[headerKey] print("请求头信息:" + headerStr) print("请求参数:\n"+res.request.body) resHeaderStr = "" for resHeaderKey in res.headers: resHeaderStr =resHeaderStr+ "\n" + resHeaderKey + ":" + res.headers[resHeaderKey] print("响应头信息:"+resHeaderStr) print("返回结果:\n"+res.content.decode("utf-8")) return res
使用:
#encoding=utf-8 ‘‘‘ Created on 2019??10??9?? @author: sea ‘‘‘ # from com.sea.hhtp.MyHttp import get, post from com.sea.hhtp import httputils print("###################################################") print("###################################################") print("################ GET ####################") print("###################################################") print("###################################################") headers = { "user-agent" : "ad", "Appstore-clientType" : "android", "Appstore-IMEI" : "123456789000000" } getheader={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36"} getresult =httputils.get("http://192.168.18.129:7016/worktable?page=1&size=2") print(str(getresult)) print("13213") print("13213") print("###################################################") print("###################################################") print("################ POST ###################") print("###################################################") print("###################################################") postresult = httputils.post("http://192.168.18.129:7016/worktable/dynamicQueryWithPage",‘{"status":"CCD","page":1,"size":2}‘,{"Content-Type":"application/json"}) print(str(postresult))
使用:
标签:agent strong ams htm roi table store import tty
原文地址:https://www.cnblogs.com/lshan/p/11643478.html