Hi,
I am trying to download/extract an image from a website but I am not able to download it using download image activity when I check the image selector it was showing base64 encoding. How do I download an image like this?
Thank you in advance
The image is embedded as Base64 (data:image/…;base64) instead of a normal URL, so Download Image won’t work.
Use Get Attribute (src) to extract the Base64 string, remove the prefix (data:image/…;base64,), convert it using Convert.FromBase64String, and save it with File.WriteAllBytes.
Cheers
Find the step by step solution
Step 1: Use Get Attribute activity on the image element. Set the Attribute property to “src” and store the output in a String variable called imageSource.
Step 2: Add an Invoke Code activity to your workflow.
Step 3: Add an input argument with Direction as In, Name as imageSource, Type as String.
Step 4: In the code editor of Invoke Code, write this code:
Dim base64Data As String = imageSource.Split(”,“c)(1)
Dim imageBytes As Byte() = Convert.FromBase64String(base64Data)
File.WriteAllBytes(“C:\Images\image.png”, imageBytes)
Note : Make sure System.IO namespace is imported. You can check this in the Imports section of the Invoke Code activity.
Try this it should work fine.
Thanks & Happy Automation
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.