python http.cookiejar Introduction














































python http.cookiejar Introduction




Introduction :

What is a cookie ?

A cookie is a file that is saved to PC , mobile or tablets. It stores the website's name and also unique id that represents us a user.  Now in python we have multiple modules to handle cookies that are saved in the system of user and one such module that helps to deal with cookies are http.cookiejar.

 

http.cookiejar is a module that define classes for the automatic handling of HTTP cookies. The use of this module is that is used to access small websites that uses small pieces of data i.e cookies to save the information of client machine by an HTTP response from a web server and then later return to server through HTTP requests.

 

Code:

import http.cookiejarurllib.request

cj = http.cookiejar.CookieJar()

opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))

r = opener.open("http://web.whatsapp.com/")

print (r)


OUTPUT:-



The output we got is the response that we get from HTTP server

Next Article :
https://cppsecrets.com/users/1380797110117112971091151051101031044948555664103109971051084699111109/Python-httpcookiejar-exception-and-classes.php


Comments