Programatically identified cookie is not getting accepted
  
 
     
     
             
                 
 
 
         up vote 
         0 
         down vote 
 
         favorite 
         
 
 
 
 
 
             
 
             
 
     
 
 I am working on a web scraper on Python 2 that reads some contents of a website. To access the contents, I need to pass a cookie. Right now, I am finding the cookie by opening the website in Chrome, and finding the cookie from site information. I am hardcoding this cookie into my scraper and getting contents from website. However, the cookies gets invalidated in some hours and then no information can be extracted from the website. To address this, I am trying to refresh the cookie in my scraper itself when a new cookie is needed.   I have tried the following two codes   First approach   import requests  import browsercookie  try:      cj = browsercookie.chrome()      session = requests.Session()      r = session.get(base_url, cookies=cj)      new_cookie = str(session.cookies.get_dict()['JSESSIONID...