How to get website cookie and use it put it in Requests.Post?

Viewed 19

I am trying to get details from website and I am able to get the work done with below mentioned code. However, the issue is I need to update cookie manually every time before I run the code. Is there a way I can get the cookie by code so I do not have to update cookie manually each time I run the code ?

   def find_part(prt_n):
   url = ''
   payload = {"searchCriteriaDto":
              {"drvd_cntrct_stat_cd":"O",
               "byr_cd":"",
               "byr_src_sys_id":"",
               "drvd_actv_dt":"",
               "page":1},
               "parts":[{"prt_nbr": str(prt_n),"prt_src_sys_id":"00111"}]}
   ck = ''
   header = {'Cookie':ck}
   response = requests.post(url, json=payload,headers=header)
0 Answers
Related