Instalando e usando o WebWhatsAPI
É preciso usar exatamente a versão selenium/standalone-firefox-debug:3.14.0-curium (ao usar versões mais novas você receberá um erro).
sudo docker run -d -p 4444:4444 -p 5900:5900 --name firefox -v /dev/shm:/dev/shm -e SCREEN_WIDTH=1366 -e SCREEN_HEIGHT=768 selenium/standalone-firefox-debug:3.14.0-curium
O /dev/shm:/dev/shm resolve o problema de estouro de memória ram que pode acontecer dentro do conteiner.
As variáveis de ambiente SCREEN_WIDTH e SCREEN_HEIGHT ajustam o tamanho da tela.
Criando um ambiente de desenvolvimento no Conda com as dependências necessárias e o Jupyter Notebook
sudo apt install -y libssl-devconda create -y --name whatsapp conda activate whatsapp conda install -y python=3.8 conda install -y pip pip install selenium pip install python-dateutil pip install python-axolotl pip install cryptography pip install aiohttp pip install six pip install typing pip install numpy pip install python-magic # Instalando o Jupyter que não buga com o asyncio pip install jupyter notebook==5.7.8 tornado==4.5.3
Acessando o Selenium via VNC
senha: secret
Erros no processo
Ao usar um Docker com Selenium e Firefox mais novo ocorrem erros:
----> 1 driver.send_message_to_id('[email protected]','hello yololo')~/whatsapp/web-whats-api-source/webwhatsapi_master/webwhatsapi/__init__.py in send_message_to_id(self, recipient, message) 566 :type message: str 567 """ --> 568 return self.wapi_functions.sendMessageToID(recipient, message) 569 570 def convert_to_base64(self, path): ~/whatsapp/web-whats-api-source/webwhatsapi_master/webwhatsapi/wapi_js_wrapper.py in __getattr__(self, item) 42 :rtype: JsFunction 43 """ ---> 44 wapi_functions = dir(self) 45 46 if item not in wapi_functions: ~/whatsapp/web-whats-api-source/webwhatsapi_master/webwhatsapi/wapi_js_wrapper.py in __dir__(self) 70 self.driver.execute_script(script.read()) 71 ---> 72 result = self.driver.execute_script("return window.WAPI") 73 if result: 74 self.available_functions = result.keys() ~/miniconda3/envs/whatsapp/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py in execute_script(self, script, *args) 632 command = Command.EXECUTE_SCRIPT 633 --> 634 return self.execute(command, { 635 'script': script, 636 'args': converted_args})['value'] ~/miniconda3/envs/whatsapp/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py in execute(self, driver_command, params) 319 response = self.command_executor.execute(driver_command, params) 320 if response: --> 321 self.error_handler.check_response(response) 322 response['value'] = self._unwrap_value( 323 response.get('value', None)) ~/miniconda3/envs/whatsapp/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py in check_response(self, response) 240 alert_text = value['alert'].get('text') 241 raise exception_class(message, screen, stacktrace, alert_text) --> 242 raise exception_class(message, screen, stacktrace) 243 244 def _value_or_default(self, obj, key, default): JavascriptException: Message: Cyclic object value