mukulhase / WebWhatsapp-Wrapper

An API for sending and receiving messages over web.whatsapp [Working as of 18th May 2018]
https://webwhatsapi.readthedocs.io/en/latest/
MIT License
2.03k stars 797 forks source link

beginners guide #941

Open collinsuzebu opened 3 years ago

sergeByishimo commented 3 years ago

This guide actually helped me. Thanks

collinsuzebu commented 3 years ago

Good to know. You're welcome. If you had to figure out additional steps, let me know too so I can add it. :)

sergeByishimo commented 3 years ago

Great, Yeah, Whatsapp on login changes the QR every 20 seconds for 5 or 6 times and then you have to click to reload your QR (which I think the driver.reload_qr() does),

So, I'm trying to figure out how to automatically catch the changed QR code every 10 seconds and save it also until it stops changing and then I have to call the driver.reload_qr() after it stopped changing.

sergeByishimo commented 3 years ago

Also saving the profile seems to not work when I re run this command :

docker run --network selenium -it -e SELENIUM='http://firefox:4444/wd/hub' -v $(pwd):/app webwhatsapi /bin/bash -c "pip install ./;pip list;python sample/remote.py"

I have to scan for the QR again.

I'm using the remote setup and using the VNC viewer

sergeByishimo commented 3 years ago

Thanks for the consideration.

collinsuzebu commented 3 years ago

I agree with previous profile not getting loaded even after been saved. There was a work around I did for a project where I used it, I'd check with the organization team if I could still get access to the private repo.

For the other problem you mentioned, the login process does not work that way. Once logged in with a qr_code, the account remain logged in. The qr_code expires quickly (<60secs) and can only be used once.

sergeByishimo commented 3 years ago

I referred to your guide and I did it like below, which seems to work, even after I restarted the containers the session was still there

profiledir = os.path.join(".", "/app/firefox_cache") # this is a directory
driver = WhatsAPIDriver(profile=profiledir, client="remote", command_executor=os.environ["SELENIUM"])
collinsuzebu commented 3 years ago

Yes, the session persist even after the container is shutdown. You could always implement a functionality that destroys created session when containers are shutdown.

Take a look at this issue for restoring previous session on startup.

sergeByishimo commented 3 years ago

Any idea on how to reuse the same window instead of creating a window every time you run a python script. Thanks.

collinsuzebu commented 3 years ago

I can't be sure, but I haven't come across the API for that. What has helped me in the passed was gracefully shutting down a window when the application quits. driver.close()