VISWESWARAN1998 / Simple-Yet-Hackable-WhatsApp-api

There is no official WhatsApp API. Here is a simple python class which satisfies the need.
Apache License 2.0
614 stars 154 forks source link

WA web got hanged up #18

Open frozenade opened 5 years ago

frozenade commented 5 years ago

It runs and just shows 'data:;' at Chrome's addressbar.

Please help

VISWESWARAN1998 commented 5 years ago

@frozenade Try updating your chrome browser and please do use the latest chrome-driver.

If you still face the issue please let me know.

frozenade commented 5 years ago

my both Chrome and Selenium driver are the latest version.

VISWESWARAN1998 commented 5 years ago

@frozenade could you please send me the code which you are using.

frozenade commented 5 years ago

I just run your code. I didn't modify the code at all.

VISWESWARAN1998 commented 5 years ago

@frozenade I seriously believe you are directly running whatsapp.py something like this,

python whatsapp.py

You should create a new file and get the object of WhatsApp class so that you can actually utilize the API.

For example, Let us create a file named group.py in the same directory where whatsapp.py and chromedriver is located with the following code,

# SWAMI KARUPPASWAMI THUNNAI

from whatsapp import WhatsApp

app = WhatsApp(10)
app.override_timeout(30)
app.join_group("https://chat.whatsapp.com/4AIA2B3GuLp4RJOKF0M8zY")
app.send_blind_message("I am in :)")

Then run, python group.py

frozenade commented 5 years ago

Ah yes. Finally it's works. But another error message comes:

Traceback (most recent call last):
  File "D:\Python\Simple-Yet-Hackable-WhatsApp-api-master\group.py", line 5, in <module>
    app = WhatsApp(10)
  File "D:\Python\Simple-Yet-Hackable-WhatsApp-api-master\whatsapp.py", line 51, in __init__
    (By.CSS_SELECTOR, '.jN-F5')))
  File "D:\Python\Python37\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
VISWESWARAN1998 commented 5 years ago

The only thing which you have do manually is to scan the QR code

10 in the constructor specifies that the API will wait for 10 seconds to scan for the code.

app = WhatsApp(10)

Specify something like 1000 to prevent this exception like this,

app = WhatsApp(1000)

So finally, test the whole code:

# SWAMI KARUPPASWAMI THUNNAI

from whatsapp import WhatsApp

app = WhatsApp(1000)
app.override_timeout(30)
app.join_group("https://chat.whatsapp.com/4AIA2B3GuLp4RJOKF0M8zY")
app.send_blind_message("I am in :)")
frozenade commented 5 years ago

Thanks but I still got error message:

==== RESTART: D:\Python\Simple-Yet-Hackable-WhatsApp-api-master\group.py ====
No alert Found
Traceback (most recent call last):
  File "D:\Python\Simple-Yet-Hackable-WhatsApp-api-master\group.py", line 5, in <module>
    app.join_group("https://chat.whatsapp.com/JKjXKduRG97L01l307FXWA")
  File "D:\Python\Simple-Yet-Hackable-WhatsApp-api-master\whatsapp.py", line 334, in join_group
    WebDriverWait(self.browser, self.timeout).until(EC.presence_of_element_located((By.XPATH, '//*[@id="app"]/div/span[3]/div/div/div/div/div/div/div[2]/div[2]')))
  File "D:\Python\Python37\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:

Is it normal?