How to use Phantomjs' cookie API?

后端 未结 1 1598
死守一世寂寞
死守一世寂寞 2021-02-03 14:06

I am trying to use rasterize.js from the phantomjs\' exmaple folder to capture a web page into PDF. The problem I am having is that the web page requires user log in. Then I saw

相关标签:
1条回答
  • 2021-02-03 14:12

    Have you tried automating the login process in PhantomJS, making sure to include cookies param? This way phantomjs can authenticate a user just like a browser would, using cookies.

    Another option would be to inspect the requests using a proxy like fiddler, compare the request made from firefox that works and the request made from phantomjs that is not authenticated. The information in the header should tell you what you are missing.

    You can add cookies by using the function phantomjs provides:

    http://phantomjs.org/api/webpage/method/add-cookie.html

    0 讨论(0)
提交回复
热议问题