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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 Download file from webpage with script task
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

enslinb
Starting Member

South Africa
4 Posts

Posted - 04/30/2015 :  08:35:23  Show Profile  Reply with Quote
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!

Edited by - enslinb on 04/30/2015 09:28:47

gbritton
Flowing Fount of Yak Knowledge

2780 Posts

Posted - 04/30/2015 :  10:19:22  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000