# Encoding: utf-8
# Date: 2019/5/30
# Name: 仲玲
import requests
from commen.read_config import Read_Config

class HTTP_Request():
	def __init__(self,logger):
		self.logger = logger
		self.config = Read_Config(logger)
		self.ip = self.config.read_config("server","ip")
		self.headers = eval(self.config.read_config("server","headers"))

	def get_request(self,url,params=""):
		self.url = url
		self.url_all = self.ip + self.url
		response = requests.get(url=self.url_all,headers=self.headers,params=params)
		return response.content

	def post_request(self,url,data):
		self.url = url
		self.url_all = self.ip + url
		response = requests.post(url=self.url_all,headers=self.headers,data=data)
		return response.content

if __name__ == '__main__':
	from commen.log_method import Log_Method
	logger = Log_Method().get_logger()
	http = HTTP_Request(logger).post_request('/iwebshop/index.php?controller=simple&action=reg_act',{'email': 'wqe@163.com', 'username': '','password':"",'repassword':""})
	with open("test.html","w",encoding="utf-8") as f:
		f.write(http.decode())



