[英]Javascript converts img src to invalid base64
I try to retrieve profile icons from web.whatsapp.com. 我尝试从web.whatsapp.com检索配置文件图标。 The source code explorer as well as with javascript retrieved img node shows me a regular static link to the image I want to get (https:....) 源代码浏览器以及使用javascript检索到的img节点向我显示了要获取的图像的常规静态链接(https:....)
Image tag retrieved with javascript 使用JavaScript检索的图片标签
Retrieving the correct src should be a trivial task but no matter if I use 检索正确的src应该是一项琐碎的任务,但是无论我是否使用
image.src or image.getAttribute('src')
I always end up with the same base64 string for what ever picture I try to fetch. 对于我尝试获取的图片,我总是以相同的base64字符串结尾。 How do I extract the src of the image tag without it being converted into gibberish? 如何提取图像标签的src,而不将其转换为乱码?
Result of the image.src image.src的结果
This was done using tampermonkey on google chrome on a mac. 这是在Mac上的Google chrome上使用tampermonkey完成的。
Edit: Additional info as per request: 编辑:根据要求的其他信息:
<img src="https://dyn.web.whatsapp.com/pp?t=s&u=4915786584978%40c.us&i=1484932082&ref=1%40%2FOBUmUFr2127pJ5jnyNl9BylFIWp6h2FiEm475nQg0gtYw%2FSf7tuwfp9&tok=1%4016ljMAEqnFIwx%2FcEvV4mq6VdicCO59U5CXvI%2FDlEBR09UnXl5bHnAXdEBO3r3zPVMNP7W4g2BWMmNw%3D%3D" draggable="false" class="avatar-image is-loaded">
The base64 string does not start with an ';'. base64字符串不以“;”开头。 This was just part of my console debug. 这只是我的控制台调试的一部分。 The plain content is shown below. 普通内容如下所示。
data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
It appeared that even though the javascript script waited for the execution until the image dom objects were created the src was not set yet. 看来,即使javascript脚本等待执行,直到创建了图像dom对象,也尚未设置src。 A small delay in the execution solved the issue 执行中的一小段延迟解决了该问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.