Does PhantomJS support cookies?

后端 未结 5 1376
攒了一身酷
攒了一身酷 2020-12-23 17:11

Does PhantomJS support cookies? If yes, where can I find the API details?

I am not able to figure it out after searching for a while now.

5条回答
  •  半阙折子戏
    2020-12-23 17:27

    It does, through WebPage.addCookie() - which incidentally doesn't work neither for me nor someone else.

    You can use this instead:

    phantom.addCookie({
        'name': 'mycookie',
        'value': 'something really important',
        'domain': 'example.com'
    })
    page.open('http://example.com/url/path/', function() {
        console.log(page.cookies);
    })
    

提交回复
热议问题