30 lines
730 B
Text
30 lines
730 B
Text
curl = require '../index'
|
|
fs = require 'fs'
|
|
util = require 'util'
|
|
p = console.info
|
|
|
|
cookieFile = 'node-curl-cookie.txt'
|
|
options = {
|
|
VERBOSE: 1
|
|
COOKIEFILE: cookieFile
|
|
COOKIEJAR: cookieFile
|
|
ACCEPT_ENCODING: 'gzip'
|
|
RAW: 1
|
|
}
|
|
curl.debug = 1
|
|
curl.setDefaultOptions options
|
|
err = curl! 'www.google.com'
|
|
p "\x1b[33m" + util.inspect(curl.info('COOKIELIST')) + "\x1b[0m"
|
|
curl.reset()
|
|
err = curl! 'www.yahoo.com'
|
|
p "\x1b[33m" + util.inspect(curl.info('COOKIELIST')) + "\x1b[0m"
|
|
p "body length #{curl.body.length}"
|
|
p "\x1b[33mText in #{cookieFile}\x1b[0m"
|
|
p "----"
|
|
stream = fs.createReadStream(cookieFile)
|
|
stream.pipe(process.stdout)
|
|
stream.on 'end', ->
|
|
p "----"
|
|
p "deleting #{cookieFile}"
|
|
fs.unlink! cookieFile
|
|
p "done."
|