0

Considering that PhantomJS isn't exactly node.js (so modules like deathbycaptcha2) are out as they use native requests, is 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?

Will this new page.open() retain cookies collected by the first page?

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
dsp_099
  • 5,801
  • 17
  • 72
  • 128

1 Answers1

1

Will this new page.open() retain cookies collected by the first page?

Yes, there exists only one CookieJar for each PhantomJS process. So every page that you create shares the same cookies. Think of those page instances as windows or tabs in a conventional browser.

[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?

That's not so easy, since the cookies are shared. If you don't access the same pages you can safely create a second instance. If you want to access the same page in the second instance then you can spin up a second PhantomJS process through the child_process module (e.g. with execFile).

Considering that PhantomJS isn't exactly node.js [...]

True, but there are several bridges between PhantomJS and node.js such as phantom, node-phantom, nightmare, etc. You can use them to interface with PhantomJS and additionally call node modules that you want.

Artjom B.
  • 61,146
  • 24
  • 125
  • 222