1

Scenario:

I am working an an auto whatsapp responder using whatsapp web.

I log in via chromedriver on selenium with python 3.

I run a function that does some stuff inside a while True.

Problem:

Sometimes, due to a lack of conectivity with the phone, or whatever other problems, the program just does not keep running the right way.

There are a lot of factors that might cause the whole thing to lose the right flow. I am analyzing them all and fixing them as best as I can.

Question:

I came up with the idea that maybe if I restart the whole thing every hour (or every whatever-thousands iterations) it would become more solid. As it will refind the flow no matter what happens, if I did not catch the bug yet.

Is it possible to restart the whole thing, without losing the browser session? Whatsapp web requires a QR scan, but it allows a "keep session alive in further connections" (which I do not really know how it works... if cookies or something else.)

Note: I know that a python script can be rebooted, but the bigger problem here is to reuse the browser session. Of course I am doing my research. None of what I read so far made me come with a solid solution, and that is why I ask to all the super cool brains out there.

2
  • the "other problems" will likely cause errors to occur in your python script. You should be catching them and dealing with them. Commented Jul 31, 2017 at 10:21
  • @asongtoruin I am doing so. Still though, there are things that I did not catch yet or which are completely out of my control. And this would be a great add-on mode. Not to ignore everything and just reboot. But to fix as much as possible and also reboot for double trouble fixer. Commented Jul 31, 2017 at 10:26

1 Answer 1

1

Whatsapp stores session in localStorage of the browser.

You can extract the localStorage and save to a file on closing of a session.

Upon instantiating a session check if this file exists, then parse the file and update localStorage with saved values before opening a URL.

Sign up to request clarification or add additional context in comments.

1 Comment

I did so but still it won't grab the session. I posted new question because it now is a new question: stackoverflow.com/questions/45415178/… - Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.