Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 Download file from webpage with script task

Author  Topic 

enslinb
Starting Member

4 Posts

Posted - 2015-04-30 : 08:35:23
Hi

I'm trying to
- download all the files on a webpage where the file name is like "cust_interact" (eg cust_interact.0815, cust_interact.0615)
(or even better, read the file date and only download today's)
- save it locally with file name and date

They are not in a specific folder but directly under http://web.address.co.za/products/scriptresults/. They're in the root directory

This is my code, which naturally makes total sense to me and only me!

Public Sub Main()

Dim strtemp As String = "\\Server\folder\folder2\folder3\CustInteraction"
Dim strsource As String = "http://web.address.co.za/products/scriptresults/"
Dim webunibase As New WebClient
Dim strdestnew As String = InStr(1, "cust_interact", strsource)
Dim strdest As String = strtemp + Date.Now.ToString("yyyyMMddhhmm") + ".csv"

For Each strdest In strdestnew
webunibase.DownloadFile(strsource, strdest)
Next

Dts.TaskResult = ScriptResults.Success
End Sub


Thanks!

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-04-30 : 10:19:22
Good for you! Though I would probably not hard-code the source or destination strings, but rather pass them to the script as variables which are configurable via SSIS Package Configurations.
Go to Top of Page
   

- Advertisement -