Closed gwilches closed 6 years ago
Is there any update on this case?
any update on sending images or video?
I need to send an image too. Did anyone discover how to do it?
is this hard or impossible ?
Hello,
I have made an attempt to send images. Basically what one has to do is enable the clicking by css element.
Which should break down to something like this:
# Click on the append button
driver.driver.find_element_by_css_selector('span[data-icon="clip"]').click()
Then one has to append open the "append" button, which should work like this:
driver.driver.find_element_by_css_selector('span[data-icon="image"]').click()
However this results in an exception. Basically what it does is to mimic a mouse click by searching for css elements. Maybe someone can work from here to imrpove this feauture?
Another option would be to mimic a draggable element
This software send images and videos: https://www.youtube.com/watch?v=x014GN_9k_0&t=6s Please guys, take a look on this software to develope some solution to send image.
any news?
Only found chat.send_message command for sending. have tried to echo MediaMessage back. With .mime, .content, .repr only can send back type, binary data, sender information. badly need help for sending image and some other media file.
Hi guys,
I found a solution but may be it not a good solution. You can automate the whole. For this you can do like...
1) Go to the screen of whom you want to send images: (Note : I'm using this according my req. you can use another approach to go there.
ph = '919874563210'
strs = 'https://api.whatsapp.com/send?phone=' + ph
search_xpath = '//*[@id="input-chatlist-search"]'
driver.driver.find_element_by_xpath(search_xpath).send_keys(phone + Keys.ENTER)
2) Click on attachment on whatsapp using : driver.driver.find_element_by_xpath('//*[@id="main"]/header/div[3]/div/div[2]/div/span').click()
3) Search the upload button like..(Note: Please change XPATH accordingly) element = driver.driver.find_element_by_xpath('//*[@id="main"]/header/div[3]/div/div[2]/span/div/div/ul/li[1]/input')
4) Use the function to send images (Note : file_path -> '/home/Desktop/image.jpg') element.send_keys(file_path) time.sleep(1)
If you have image URL in that case you can download image first using and then use above help.
folder_path = '/home/Desktop/' URL = ['image1_url', 'image2_url'] (Please put your URL here) def download_images_with_url(URL): for index, url in enumerate(URL): file_object = str(index) + '.jpg' file_path = os.path.join(folder_path, file_object) try: urllib.urlretrieve(url, file_path) except Exception as e: print(e)
Surely it will help to send an image.
any news about this?
Hey guys, I am sendind images now.
There are too many things to do to send images using JS:
So I Gave up.
And I decided to take a different route, actually it is the same @bansal95 was explaining. I create a full script to send the images in selenium.
I hope it helps,
Would you kindly share or implement the Implementation? It would be a great Feature for this API
Btw, in this way it would also be possible to Senf any Kind of different Attachment (just Change the click on attach file). That'd be nice to have, maybe we can Work Something Out
Greetings
Am 21.02.2018 12:44 vorm. schrieb "gwilches" notifications@github.com:
Hey guys, I am sendind images now.
There are too many things to do to send images using JS:
- Upload the file to Whatsapp Server
- Receive the URL with whatsapp Server Validation
- Send the image to the group using the validation URL plus other params.
So I Gave up.
And I decided to take a different route, actually it is the same @bansal95 https://github.com/bansal95 was explaining. I create a full script to send the images in selenium.
- Fill the search text with the group or contact I want to send the image
- Click on the Clip icon.
- Fill the File Input with the location of the image
- Click on the send button.
I hope it helps,
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mukulhase/WebWhatsAPI/issues/23#issuecomment-367161443, or mute the thread https://github.com/notifications/unsubscribe-auth/AGhecaYIdfW1gF_GU0eoi53_2Xk0VJKmks5tW1jngaJpZM4P_sKr .
@gwilches Thanks for feedback! I'm sending image too like you. The problem is sometimes Whatsapp change some properties on html like class names or path. so it's hard to keep de code up to date. Can you describe how do you send file to whatsapp server? You did this?
@m2datacenter @gwilches If you can send the script that'd be awesome.
@gwilches can get a email to contact please? @gwilches
@gwilches could you please share your solution?
I can send image in a simple way. Just send the image to the clipboard and with the chat open, paste. Then click on the submit button
@wallysonn can explain more this solution?
@wallysonn could you please explain your solution?
@gwilches : Can you please share the code ?
Here is the code in puppeteer
Someone please port it to selenium.
@kevinkit @mukulhase Please look at the code
Actually, I just looked a little bit at the WAP given from Whatsapp and found that there is a"sendMedia" function in Javascript implemented.
It can be found with:
window.Store.Wap.sendMedia
I think this is they way to go, since it will automatically be updated and not depend on css or html paths and names.
However, I was not able to reverse engineer this function or its parameters, since I am far far away from the javascript world.
Hello, Is there any built in functionality for sending any image or file to any contact, I have tried above methods but it throws an exception "Element could not be scrolled into view" Thanks in advance
Hi guys, I did like @bansal95 suggested, I know this isn't the best way to do it but at least it works just fine although, I'm having a little problem with large files (+20 megas), getting the error of maximum Heap size of Java. Here is how I did it:
phone = 'XXXXXXXXX'
#This is the Header of the input where you look for the contact, its in portuguese
search_xpath = '//*[@title="Procurar ou começar uma nova conversa"]'
driver.driver.find_element_by_xpath(search_xpath).send_keys(phone + Keyss.ENTER)
#This part clicks on the attachment button
driver.driver.find_element_by_xpath('//*[@title="Anexar"]').click()
time.sleep(1)
#Gets the photo/video input, you can alter the last li[1] for other type of input
element = driver.driver.find_element_by_xpath('//*[@id="main"]/header/div[3]/div/div[2]/span/div/div/ul/li[1]/input')
#Make the input visible
driver.driver.execute_script("arguments[0].setAttribute('style', 'block')",element)
url = "http://pm1.narvii.com/6448/92e4dd26d8b6bf69e23c4eb9b417b9ea53bc25a1_00.jpg"
file_path = "/app"
filename = "galocego.jpg"
fullfilename = os.path.join(file_path, filename)
urllib.urlretrieve(url, fullfilename)
element. send_keys("/app/galocego.jpg")
time.sleep(2)
#Clicks on the send button
driver.driver.find_element_by_xpath('//*[@id="app"]/div/div/div[1]/div[2]/span/div/span/div/div/div[2]/span[2]/div/div').click()
I placed a text next to the image, but I'm not able to break the line, the \ n 'does not work, could someone help me?
Removed comments due to language violation.
Also see #279 for further insturctions on how to send media
@wallysonn
elem = driver.driver.find_element_by_class_name ('_ 2S1VP')
time.sleep (2)
elem.send_keys (caption)
I am sending this way, if I put the <br>
it interprets as "hello '< br >' world"
@WilliamCampolina please format your code in the future
@kevinkit stop fresh
@wallysonn Excuse me, I do not know what that statement is supposed to mean. Please elaborate
@wallysonn Do you send images?
@WilliamCampolina yes.
Do you send caption with image?
@WilliamCampolina yes. Submission with the function available right here in the API. I just made some adjustments.
@WilliamCampolina use this function: window.WAPI.sendImageFromDatabasePicBot
@wallysonn I'll take a look and try to use ... do you have a telegram?
A brief explanation to use this function window.WAPI.sendImageFromDatabasePicBot
@wallysonn new function -> https://github.com/mukulhase/WebWhatsapp-Wrapper/pull/300
Hey, Here is the code for send media file(like image) just by convert file to base64 ( here is url for convert image to base64 https://www.base64-image.de/ ) and use this function
window.send_media("919999999999@c.us", "file base64 string", "test messsage", null, null);
And here is full code https://gist.github.com/phpRajat/a6422922efae32914f4dbd1082f3f412
Hey , How can I send an Image, I was trying to found the correct function but it is really hard to find.