Monday 15 February 2010

How to add a cookie to the cookiejar in python requests library -


I am trying to add cookies to an existing cookie using the Python Requests 1.2.3 library. Every time I add a new cookie, the data of the jar is groundnut for the new cookie. Key missing, wrong value matches missing or incorrect key. I'm not sure whether this is a request library bug or I'm not sending the cookie correctly. I am using the following code as a result of which cookies have cook cookies. Am I formatting the cookie correctly? Any ideas?

  my_cookie = {'domain': 'www.mydomain.com', 'expired': none, 'name': 'COOKIE_NAME', 'path': '/', 'value ':' Cookie work ',' version ': 0} s = request Session () Request. Utils.add_dict_to_cookiejar (s.cookies, my_cookie)    

Cookies, Cookies, and Cookies One way to do this is by importing it. With help from @Lukasa, she showed me a better way though, in my own way I was not able to specify "port_specified", "domain_specified", "domain_initial_dot" or "path_specified" attributes. The "set" method automatically does with the default values. I am trying to scrape a website and those attributes have different values ​​for their cookies. As I'm new to all of this, I'm not sure that really matters anyway so far. "," "Name": 'COOKIE_NAME', "value": 'true', "port": none, # "port_specified": False, " False "," path ": '/', #" path_specified ": True," safe ": wrong," end ":" false "," end " : None, "reject": true, "comment": none, "comment_url": none, "rest": {}, "rfc2109": wrong} s = request Sessions () s.cookies.set (** my_cookie)

No comments:

Post a Comment