gpt4 book ai didi

python - 一个奇怪的需求:)的多线程python程序

转载 作者:行者123 更新时间:2023-12-04 16:20:41 25 4
gpt4 key购买 nike

使用 mechanize 模块在 python 中可以执行以下操作吗?

Having 2 threads in a program, both accessing the same web server, but one of them is actually logged into the server with a user/pass, while the other thread is just browsing the same web server without logging in.



我看到如果我使用 mozilla 登录到网络服务器(比如 X),然后我打开 chrome 我不会自动登录,我必须再次登录 chrome。我想在 python 多线程程序中具有相同的行为,其中一个线程已登录,另一个未登录。
什么是合适的方法来做到这一点?

感谢您的任何提示!

最佳答案

只需使用 mechanize.Browser 的两个不同实例.由于两者都使用自己的处理程序链,因此它们不共享 cookie、登录名等......无论您是否从不同的线程使用它们并不重要,它们在任何情况下都是完全隔离的。

关于python - 一个奇怪的需求:)的多线程python程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18879888/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com