Node JS browser simulation (cookies, sessions, headers)

Viewed 24612

I need to make requests from node js like a normal browser. What do I mean ?

  1. I can set any HTTP information, like cookies, headers, body. So to built HTTP request as I want.
  2. After the request is made, all response data should be readable, like Set Cookie....
  3. It would be great if cookies could be saved automatically for the time of a session. So I don't need to include them each time all further request are made.
  4. So just simulate a real browser in order to keep session

Is there any library of framework that could provide such functionality ?

2 Answers

With the latest versions of Chrome/Chromium you can use them directly in headless mode.
Here's the package that adds Chromium to your NodeJS project and allows to perform automation in headless mode: https://github.com/dtolstyi/node-chromium

Related