示例#1
0
 def send_post(self,
               url,
               data,
               cookie=None,
               get_cookie=None,
               herader=None) -> object:
     """
     post_request
     :param url:
     :param data:
     :return:
     """
     data = json.dumps(data)
     print(datetime.now())
     response = requests.post(url=url,
                              data=data,
                              cookies=cookie,
                              heraders=herader)
     print(datetime.now())
     if get_cookie != None:
         """
         {"is_cookie":"app"}
         """
         cookie_value_jar = response.cookies
         cookie_value = requests.utils.dict_from_cookiejar(cookie_value_jar)
         write_cookie(cookie_value, get_cookie['is_cookie'])
     res = response.text
     return res
示例#2
0
    def send_get(self,url,data,cookie=None,get_cookie=None,header=None):
        '''
        发视get请求
        '''
        response = requests.get(url=url,params=data,cookies=cookie,headers=header)
        if get_cookie !=None:
            cookie_value_jar = response.cookie
            cookie_value = requests.utils.dict_from_cookiejar(cookie_value_jar)
            write_cookie(cookie_value,get_cookie['is_cookie'])

        res = response.text
        return res
示例#3
0
 def send_post(self,url,data,cookie=None,get_cookie=None,header=None):
     '''
     发送post请求
     '''
     response = requests.post(url=url,data=data,cookies=cookie,headers=header)
     if get_cookie !=None:
         '''
         {"is_cookie":"app"}
         '''
         cookie_value_jar =  response.cookies
         cookie_value = requests.utils.dict_from_cookiejar(cookie_value_jar)
         write_cookie(cookie_value,get_cookie['is_cookie'])
     res = response.text
     return res
示例#4
0
 def send_get(self,
              url,
              data,
              cookie=None,
              get_cookie=None,
              herader=None) -> object:
     """
     get_request
     :param url:
     :param data:
     :return:
     """
     response = requests.get(url=url,
                             params=data,
                             verify=False,
                             cookies=cookie,
                             heraders=herader)
     if get_cookie != None:
         cookie_value_jar = response.cookies
         cookie_value = requests.utils.dict_from_cookiejar(cookie_value_jar)
         write_cookie(cookie_value, get_cookie['is_cookie'])
     res = response.text
     return res