1.0.3 • Published 7 years ago

phantom2jar v1.0.3

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

Phantom2JAR

NPM

Export PhantomJS' cookies to tough-cookie easily.

You can use the tough-cookie's JAR with others request library.

Install

npm install phantom2jar --save

Usage

Here's a basic example opening a webpage and extracting the created cookies from them.

const phantom2jar = require('phantom2jar')
const phantom = require('phantom')

(async function() {
  // Initialize phantomjs
  const instance = await phantom.create()
  const page = await instance.createPage()

  // Do your requests with the page
  const stackoverflow = await page.open('https://stackoverflow.com/')
  let jar = await phantom2jar(instance) // This will return a though-cookie jar

  // You can plug it with any other lib that use though-cookie :)
  
  // Do whatever you want...
})()