Esempio n. 1
0
 def getFile(self,path,storeFilePath,params=None,**kwargs):
     """
     下载文件
     :param path:
     :param storeFilePath:
     :param params:
     :return:
     """
     r=requests.get(self._url+path,params=params,headers=self._headers, cookies=self._cookies, timeout=self._timeout,
                    proxies=self._proxies,**kwargs)
     httpResponseResult=HttpResponseResult()
     httpResponseResult.status_code=r.status_code
     httpResponseResult.headers=self._session.headers.__str__()
     httpResponseResult.cookies=self._session.cookies.__str__()
     with open(storeFilePath,"wb") as f:
         f.write(r.content)
     return httpResponseResult
Esempio n. 2
0
 def _dealResponseResult(self, r):
     """
     将请求结果封装到HttpResponseResult
     :param r: requests请求响应
     :return:
     """
     r.encoding = self._encoding
     httpResponseResult = HttpResponseResult()
     httpResponseResult.encoding = r.encoding
     httpResponseResult.status_code = r.status_code
     httpResponseResult.headers = self._session.headers.__str__()
     httpResponseResult.cookies = self._session.cookies.__str__()
     httpResponseResult.body = r.content
     return httpResponseResult