Resource Downloader
SγиtαxEяяoя:
Hola, me preguntaba si se puede hacer un programa que descargue todos los recursos de una pagina "Juego Flash"
Tengo las "ID's" de los archivos algo asi por ejemplo
http://www.juego.com/juego/swf/id/001.swf
http://www.juego.com/juego/swf/id/002.swf
http://www.juego.com/juego/swf/id/003.swf
http://www.juego.com/juego/swf/id/004.swf
http://www.juego.com/juego/swf/id/005.swf
y se me toma muy molesto estar cambiando los "ID" de cada .swf
¿Existe alguna manera de hacerlo mas rapido? algo asi de poner todas las ID's en un "File.txt" y que el programa pase de Id, en Id y las descargue
Eleкtro:
No estoy delante de la IDE, si hay algun error de sintaxis corrígelo:
Código
' dim strarray() as string = io.file.readalllines("C:\ids.txt")
for each ID as string in io.file.readalllines("C:\ids.txt"): downloader(ID) : next
private sub downloader(byval ID as string)
' descargar ID
dim url = nothing
try : url = new uri(ID) : catch : msgbox("Enlace no válido"): end try
...
end sub
SγиtαxEяяoя:
Código
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim client As WebClient = New WebClient
AddHandler client.DownloadProgressChanged, AddressOf client_ProgressChanged
AddHandler client.DownloadFileCompleted, AddressOf client_DownloadCompleted
client.DownloadFileAsync(New Uri("http://d1hmtg1vead5c8.cloudfront.net/sr/images/ships/swf_big_1.5.4/" & ListView1.SelectedItems(0).Text & ".swf"), (".\Archivos\") & ListView1.SelectedItems(0).Text & ".swf")
Button1.Text = "Please Wait"
Button1.Enabled = False
'If ListView1.SelectedItems.Count > 0 Then
' My.Computer.Network.DownloadFile("http://d1hmtg1vead5c8.cloudfront.net/sr/images/ships/swf_big_1.5.4/" & ListView1.SelectedItems(0).Text & ".swf", (".\Archivos\") & ListView1.SelectedItems(0).Text & ".swf")
'End If
End Sub
Private Sub client_ProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs)
Dim bytesIn As Double = Double.Parse(e.BytesReceived.ToString())
Dim totalBytes As Double = Double.Parse(e.TotalBytesToReceive.ToString())
Dim percentage As Double = bytesIn / totalBytes * 100
progressBar1.Value = Int32.Parse(Math.Truncate(percentage).ToString())
End Sub
Private Sub client_DownloadCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs)
Button1.Text = "Start Download"
Button1.Enabled = True
ProgressBar1.Value = 0
End Sub
Esto es algo de lo que llevo, como puedo integrar tu codigo con el mio.. es decir como puedo hacer que al presionar el "Button1" se descargue todo lo que hay en el "Listview1"
z3nth10n:
Sencillo:
Código
For Each ID In ListBox1.Items
My.Computer.Network.DownloadFile(ID, ".\Archivos\" & ListView1.SelectedItems(0).Text & ".swf")
Next
No estoy seguro si va a funcionar, pero la idea seria algo así. ;)
Eleкtro:
Haces un ciclo en la colección de items del Listbox, y listo, como te ha comentado IkillNukes.
Saludos
Navegación
[#] Página Siguiente