How Download Image From URL

I have 100x Image URL and i want UiPath to Download and Save in a Folder.

any one have idea how to do this?

im scraping websites and i have problem downloading prdocuts image

thank you.

3 Likes

First, you should find a way to get all the Image URLs.

Then go through each of them (For Each activity) and open each image in the browser - so the image is opened with it’s own URL. After this, it is UI Automation:

Send a HotKey : CTRL+S to save the image. This will open the confirmation window. Enter for confirmation.

(You could also select the folder in the confirmation window - this is optional, you can download in the default folder and move them later).

Hope this helps!
Vlad

3 Likes

Can’t attach a .nupkg, hopefully you know how to build an activity from C# code (there are tutorials for that in Resources section). Code - WF activity to download and save image from URL - Pastebin.com

Usage should be pretty straightforward, if anything is unclear, don’t hesitate to ask.

Note: ImageFormatToUse does not need to be the same as the downloaded image, it will convert.
It uses System.Drawing.Image, not UiPath.Core.Image, but once saved to disk, you can LoadImage with built-in activities if you need it in that format.

Regards.

Edit:
Now with the .nupkg attached.

DownloadImageActivities.nupkg (5.2 KB)

6 Likes

Hi @andrzej.kniola

I installed your DownloadImageActivities.nupkg package and put the parameter values correctly. But it has encountered an error when I run. Error message is as below. Can you help me to solve this?


Main has thrown an exception

Message: Cannot create unknown type ‘{clr-namespace:WebHelpers.DownloadImageFromUrl;assembly=DownloadImageFromUrl}DownloadAndSaveImage’.

Source: System.Xaml

Exception Type: XamlObjectWriterException

System.Xaml.XamlObjectWriterException: Cannot create unknown type ‘{clr-namespace:WebHelpers.DownloadImageFromUrl;assembly=DownloadImageFromUrl}DownloadAndSaveImage’.
at System.Xaml.XamlObjectWriter.WriteStartObject(XamlType xamlType)
at System.Xaml.XamlWriter.WriteNode(XamlReader reader)
at System.Xaml.XamlServices.Transform(XamlReader xamlReader, XamlWriter xamlWriter, Boolean closeWriter)
at System.Activities.XamlIntegration.FuncFactory1.Evaluate() at System.Activities.DynamicActivity.OnInternalCacheMetadata(Boolean createEmptyBindings) at System.Activities.Activity.InternalCacheMetadata(Boolean createEmptyBindings, IList1& validationErrors)
at System.Activities.ActivityUtilities.ProcessActivity(ChildActivity childActivity, ChildActivity& nextActivity, Stack1& activitiesRemaining, ActivityCallStack parentChain, IList1& validationErrors, ProcessActivityTreeOptions options, ProcessActivityCallback callback)
at System.Activities.ActivityUtilities.ProcessActivityTreeCore(ChildActivity currentActivity, ActivityCallStack parentChain, ProcessActivityTreeOptions options, ProcessActivityCallback callback, IList1& validationErrors) at System.Activities.ActivityUtilities.CacheRootMetadata(Activity activity, LocationReferenceEnvironment hostEnvironment, ProcessActivityTreeOptions options, ProcessActivityCallback callback, IList1& validationErrors)
at System.Activities.Hosting.WorkflowInstance.ValidateWorkflow(WorkflowInstanceExtensionManager extensionManager)
at System.Activities.Hosting.WorkflowInstance.RegisterExtensionManager(WorkflowInstanceExtensionManager extensionManager)
at System.Activities.WorkflowApplication.EnsureInitialized()
at System.Activities.WorkflowApplication.Enqueue(InstanceOperation operation, Boolean push)
at System.Activities.WorkflowApplication.SimpleOperationAsyncResult.Run(TimeSpan timeout)
at System.Activities.WorkflowApplication.BeginRun(AsyncCallback callback, Object state)
at UiPath.Executor.RobotRunner.<>c__DisplayClass49_0.b__0()

Thanks,

Hi,

To download an image from an URL you can simply use HTTP Request activity with the URL set to EndPoint property and the local file name where you want to save it set in ResourcePath property.
The HTTP Request activity can be found in UiPath.Web.Activities pack.
I attached an example that downloads the UiPath logo and saves it next to the workflow.

Cheers,
Lavinia

Main.xaml (4.7 KB)

23 Likes

Hi,

Can’t replicate that issue unfortunately.

You could try doing the following:

  1. Close the project (Start → Close)
  2. Press the back arrow (top left corner) to go back to Studio view.
  3. Uninstall the package.
  4. Close the Studio.
  5. Open the Studio.
  6. Go to studio view (don’t open any project).
  7. Install the package.
  8. Open your project.

I’ve seen some situations where the installation is not cached, refreshing/reinstalling it like this usually helps. There seems to be some issue with cache not getting refreshed/not registering in some instances.

Also make sure you’ve added System.Drawing.Imaging to the Imports namespaces for ImageFormat enum to work without specifying fully qualified name.

Thank you @Lavinia. It works!

Hello @Lavinia @andrzej.kniola,

I am having a similar problem. I need to download PDF files from URL fetched from email body. The link is actually meant to be clicked on to save the file. I am trying to automate this using HTTPRequest activity. I am able to save a file, but unable to open it. It says the file corrupted. I posted a question here. Can you please help resolve it?

Did you get this solved? I have the same problem… :neutral_face:

Did you receive any error when using HTTP Request activity? what difficulty are you facing?

I do not get any errors at all, and the file seemingly downloads ok, but the downloaded file is truncated to about 3-4KB. I am trying to download .pdf and .xlsx files using HTTP Request activity. I have set the “Endpoint” and “Resource Path” properties, and the endpoint is a public facing website where credentials are not required.

Cheers,
Jeppe

1 Like

Once you have the URL for the file to be downloaded (could be image, excel, doc) just use “Navigate To” activity with that URL. The download dialog will open.
After that select the “Save” option and enter the directory path (you may record this path or manually place the activities).

1 Like