What information about device does cookie store?

前端 未结 2 1567
借酒劲吻你
借酒劲吻你 2021-01-27 20:31

I\'m using selenium to collect cookies, and here\'s the question: does cookies store information about selenium?

相关标签:
2条回答
  • 2021-01-27 20:53

    No, cookies doesn't store information about Selenium.


    Cookies

    As per the article Privacy Concerns on Cookies, cookies are harmless. In it's basic form, cookies are simple uncompiled text files that help coordinate the remote website servers and your browser to display the full range of features offered by the websites. These features may include hassle-free automatic logins and authentication, third party ad serving, ad management, preference settings, language settings, etc.


    Tracking User Behavior

    While cookies by themselves cannot dig or research your information or search your computer, they do store personal information in at least two ways:

    • Form information and
    • Ad tracking

    This personal information is not generated by the cookies themselves but by your own input into website order forms, registration pages, payment pages, and other online forms.


    Demonstration

    A simple example to demonstrate the information stored by cookies using pickle is as follows:

    • Code Block:

      import pickle
      import selenium.webdriver 
      import time
      
      driver = selenium.webdriver.Firefox()
      driver.get("http://www.google.com")
      pickle.dump( driver.get_cookies() , open(r'C:\Utility\testdata\my_cookies.pickle',"wb"))
      driver.quit()
      pickle_off = open(r'C:\Utility\testdata\my_cookies.pickle',"rb")
      personOut = pickle.load(pickle_off)
      print(list(personOut))
      
    • Console Output:

      [{'name': '1P_JAR', 'value': '2020-02-21-14', 'path': '/', 'domain': '.google.com', 'secure': True, 'httpOnly': False, 'expiry': 1584888349}, {'name': 'NID', 'value': '198=DCEMsfy3h6nZ0vpi6p3m3J-vVJpDlUBc7ItYE99kbFtr2fssl-1nVVXqF6joPREjrW-X8yxe5PnDqMNiVaVUd0NY8S_YOfksQdb-SzKSPUP5XumjlTjyTt_C8a5XSOmpUuXnOu-JCXHDe71fTe2KC-0kwb5B7_N7wSzM6Jrozqs', 'path': '/', 'domain': '.google.com', 'secure': True, 'httpOnly': True, 'expiry': 1598107549}]
      
    0 讨论(0)
  • 2021-01-27 20:55

    You can check the cookies list by driver.manage().getCookies(); Return type is Set <Cookies>.

    Hope this will help.

    0 讨论(0)
提交回复
热议问题