Skip to content

Instantly share code, notes, and snippets.

@cocodrips
Last active August 29, 2015 14:10
Show Gist options
  • Save cocodrips/f93a4e61f43f071e1f87 to your computer and use it in GitHub Desktop.
Save cocodrips/f93a4e61f43f071e1f87 to your computer and use it in GitHub Desktop.
CasperJS メモ

Cookie

参考:casperjsでのクッキーの保存、読み込み
基本的にはこれで動く。casperなのに、かすかに見え隠れするphantom.js...

Save

var fs = require('fs')
var cookies = JSON.stringify(phantom.cookies)
fs.write("cookie.txt", cookies, 644)

Load

var fs = require('fs')
var data = fs.read("cookie.txt")
phantom.cookies = JSON.parse(data)

Read json

hoge.json

{"foo": "hoge"}
hoge = require 'hoge.json'
hoge.foo

Options

casperjs test tests/ --includes=inc.coffee --pre=login.coffee --foo=hoge

@echo casper.cli.options.foo
> hoge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment