考虑到 PhantomJS 不完全是 node.js(因此像 deathbycaptcha2 这样的模块)因为它们使用 native 请求而被淘汰,是否可以简单地打开 webpage
的另一个实例并使用它来在不影响其他页面实例的情况下向验证码 API 发送 POST 请求?
这个新的 page.open()
会保留第一页收集的 cookie 吗?
最佳答案
Will this new
page.open()
retain cookies collected by the first page?
是的,每个 PhantomJS 进程只有一个 CookieJar。因此,您创建的每个 页面
共享相同的 cookie。将那些 page
实例视为传统浏览器中的窗口或选项卡。
[I]s it possible to simply open another instance of webpage and use it to send POST requests to the captcha API without affecting the other page instance?
这并不容易,因为 cookie 是共享的。如果您不访问相同的页面,您可以安全地创建第二个实例。如果你想在第二个实例中访问同一个页面,那么你可以通过 child_process
module 启动第二个 PhantomJS 进程。 (例如使用 execFile
)。
Considering that PhantomJS isn't exactly node.js [...]
是的,但是 PhantomJS 和 node.js 之间有几个桥梁,例如 phantom , node-phantom , nightmare等。您可以使用它们与 PhantomJS 交互,并另外调用您想要的节点模块。
关于javascript - 在不中断 session 的情况下将 deathbycaptcha 与 phantomjs 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32364092/