使用时web.whatsapp.de网站可以看到,指向接收图像的链接可能如下所示:
blob:https://web.whatsapp.com/3565e574-b363-4aca-85cd-2d84aa715c39
如果链接被复制到一个地址窗口,它将打开图像,然而,如果“blob”被忽略了,它只会打开一个新的webwhatsapp窗口。在
我正在尝试下载这个链接显示的图像。在
但是使用常见的技术,例如使用请求,或者urllib.请求甚至BeautifulSoup总是在一个点上挣扎:url开头的“blob”会抛出一个错误。在
这些答案Download file from Blob URL with Python将尝试显示错误
^{pr2}$或者错误
InvalidSchema: No connection adapters were found for 'blob:https://web.whatsapp.com/f50eac63-6a7f-48a4-a2b8-8558a9ffe015'
(用BeatufilSoup)
使用本地方法,如:
import requests
url = 'https://web.whatsapp.com/f50eac63-6a7f-48a4-a2b8-8558a9ffe015'
fileName = 'test.png'
req = requests.get(url)
file = open(fileName, 'wb')
for chunk in req.iter_content(100000):
file.write(chunk)
file.close()
只会导致与使用beauthulsoup相同的错误。在
我在Python中使用Selenium控制Chrome,但是我无法使用提供的链接正确下载图像。在
blob是浏览器存储的原始数据的类似文件的对象。在
您可以在
chrome://blob-internals/
上看到它们通过脚本注入可以获得一个带有硒的blob的内容。但是,您必须通过在创建blob的页面/域上运行脚本来遵守跨源策略:
对于在node和selenium中尝试相同操作的人,请参考下面的内容。在
有关详细说明,请参阅下面的链接 https://medium.com/@anoop.goudar/how-to-get-data-from-blob-url-to-node-js-server-using-selenium-88b1ad57e36d
Blobs不是要由URI远程检索的实际文件。相反,它们是编程生成的psuedo url,映射到二进制数据,以便给浏览器一些参考。一、 e.没有
<img>
属性来提供原始数据,因此您可以创建一个blob地址来将该数据映射到标准的src
属性。在从上面链接的MDN页面:
相关问题 更多 >
编程相关推荐