alwex / php-casperjs

simple PHP wrapper for CasperJS
MIT License
182 stars 68 forks source link

casperjs persistent Login #61

Open Gobmichet opened 5 years ago

Gobmichet commented 5 years ago

Hi, I'm developping a Symfony 4 application to scrap Linkedin profiles. The scrap is meant to be done in different steps, each one triggered by a user click. Therefore, i'd want to persist the Linkedin connexion in order to avoid the reconnexion each time.

I started with symfony/panther to do the scrapping stuff. I first developped all the scrapping logic, and when i tried to "connect" this to my symfony app i got stuck 'cause the $client used looses the linkedIn connexion between each steps...

that's been 4 days i'm trying to find a way to achieve this in symfony/panther but it just seems to be impossible... people even tell me this is not possible on the issue i opened on its github...

So my question is, is it possible with CasperJS, and with php-CasperJS ?

and if so, could someone show me some code to achieve this please ?

Thanks in advance for your help

JeanHules commented 5 years ago

I am also interested in keeping the crawler logged in. Were you able to find a solution?

Gobmichet commented 5 years ago

Nop, indeed i was waiting for an answer before "throwing away" symfony/panther and get casperJS instead...

Nevertheless, i spend few minutes on it and it would be possible in CasperJS, in it's javascript version by overriding a certain method redefining it's constructor...

but 1 - didn't try myself yet 2 - don't know if it's possible in php-casperjs...

So, "up" on this post ;)

cdunca commented 4 years ago

Hi there,

I have had the same issue a while ago and I went with the following solution:

$casper->addToScript( ' var cookie = cookieObject; var domain = "www.google.com"; // I was interested in one domain only cookie.split(";").forEach(function(pair){ pair = pair.split("="); phantom.addCookie({ \'name\': pair[0], \'value\': pair[1], \'domain\': domain }); }); ' );