javascript python selenium url whatsapp

How to download an image with Python 3/Selenium if the URL begins with “blob:”?

When using one can see that the link to a recieved image may look like this:


If the link is copied in to an address window it will open up the image, however – if “blob” is left out – it will simply open a new web whatsapp window.

I am trying to download the image displayed by this link.

But using common techniques such as using request, or urllib.request or even BeautifulSoup always struggle at one point: The “blob” at the beginning of the url will throw an error.

These answers Download file from Blob URL with Python will trhow either the Error

URLError: <urlopen error unknown url type: blob>

or the Error

InvalidSchema: No connection adapters were found for 'blob:'

(using BeatufilSoup)

Using a native approach like:

import requests
req = requests.get(url)
file = open(fileName, 'wb')
for chunk in req.iter_content(100000):

Will simply result in the same error as using BeautifulSoup.

I am controlling Chrome using Selenium in Python, however I was unable to download the image correctly using the provided link.