简体   繁体   English

如何将 cookies 导出到 txt 文件?

[英]how to export cookies to txt file?

from COOKIESQ import ChromeCookieJar
jar = ChromeCookieJar()
jar.load()

jar.save("C:\ProgramData\cks.txt", ignore_discard=True)

i get this error i tried searching but i couldnt find anything.我收到此错误,我尝试搜索但找不到任何东西。

File "c:\Users\xxx\Desktop\c0OK13\cdemo.py", line 14, in <module>
    jar.save("C:\ProgramData\cokisqqq.txt", ignore_discard=True)   File "C:\Users\xxx\AppData\Local\Programs\Python\Python39\lib\http\cookiejar.py", line 1790, in save
    raise NotImplementedError() NotImplementedError

What is COOKIESQ - where does that come from?什么是COOKIESQ - 它从何而来?

Evidently you are using an implementation of ChromeCookieJar which subclasses FileCookieJar , which if you look at line 1790 of Python39\lib\http\cookiejar.py will show you that FileCookieJar does not implement save() .显然,您正在使用ChromeCookieJar的一个实现,它是FileCookieJar的子类,如果您查看Python39\lib\http\cookiejar.py的第 1790 行,您会发现FileCookieJar没有实现save()

For example this ChromeCookieJar implementation .例如这个 ChromeCookieJar 实现

According to the CookieJar documentation , the save() method of class FileCookieJar "...raises NotImplementedError. Subclasses may leave this method unimplemented."根据CookieJar 文档,class FileCookieJarsave()方法“...引发 NotImplementedError。子类可能未实现此方法。”

Therefore, your problem is that the implementation of ChromeCookieJar you are using does not implement the save() method.因此,您的问题是您使用的ChromeCookieJar的实现没有实现save()方法。 But you knew that already from reading the error message.但是您已经通过阅读错误消息知道了这一点。

If you want some guidance as to how to implement saving of cookies, look at the implementations of save() in the LWPCookieJar and MozillaCookieJar classes in Python39\lib\http\cookiejar.py .如果您需要有关如何实现 cookies 保存的一些指导,请查看Python39\lib\http\cookiejar.pyLWPCookieJarMozillaCookieJar类中save()的实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM