好的。所以這裏有一個可能的解決方案。
不幸的是,它只適用於鏈接完成。 (以http://開頭......)
Imports System.Text.RegularExpressions
Imports System.IO
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
ScanForZIPs()
End Sub
Private Sub ScanForZIPs()
Dim Reader As New StreamReader("<path to the downloaded webpage>")
Dim HTMLSource As String = Reader.ReadToEnd()
Dim Pattern As String = "(?<Protocol>\w+):\/\/(?<Domain>[\[email protected]][\w.:@]+)\/?[\w\.?=%&=\[email protected]/$,]*" 'Pattern, which the Regex will use in order to match links in the webpage.
'Credits to IronRazerz (https://social.msdn.microsoft.com/profile/ironrazerz/?ws=usercard-mini) for giving me a fully working pattern.
Dim RgEx As New Regex(Pattern, RegexOptions.IgnoreCase) 'Define the Regex.
Dim mc As MatchCollection = RgEx.Matches(HTMLSource) 'Check for matches in the HTML source.
Dim MatchList As New List(Of String) 'List of strings for the matched links.
For Each m As Match In mc 'Loop through each match.
MatchList.Add(m.Value) 'Add the value (link) of each match to the MatchList.
Next
Dim ZipsList As New List(Of String) 'List of links that ends with .zip.
For Each s As String In MatchList 'Loop through each string in MatchList.
If s.ToLower.ToString.EndsWith(".zip") = True Then 'Check if the link ends with .zip.
ZipsList.Add(s) 'Add the link to the list.
End If
Next
MessageBox.Show(ZipsList.Count & " .zip files found", "", MessageBoxButtons.OK, MessageBoxIcon.Information) 'Display how many .zip files were found on the page.
Dim SelectZip As New SelectDownload 'Define a new download form.
For Each z As String In ZipsList 'Loop through the found .zip links.
SelectZip.ListBox1.Items.Add(z) 'Add them to the list in the SelectZip form.
Next
SelectZip.ListBox1.HorizontalScrollbar = True 'Horizontall scrollbar in SelectZip's ListBox.
SelectZip.ShowDialog() 'Display the SelectZip form.
End Sub
End Class
SelectDownload表單。 :)
如果你能夠從任何網站下載的紋理包,而不僅僅是特定的一個:這可能將是非常困難的,因爲有相當多沒有辦法爲你的應用程序知道你的下載。按照您的建議進行操作可能會有效,但問題在於,如果在該頁面上的紋理包之前還有更多下載,則可能會找到其他下載。由於紋理包位於.zip文件中,因此它會檢查鏈接是否以「.zip」結尾,或者鏈接的最後部分(最後一個「/」後面的所有內容)是否包含「.zip」。請注意,某些地址可能以「/blablabla.zip?forcedownload」結尾。 –
好的,如果除了我建議的方法之外沒有其他方法,那麼我將如何去編碼? –
對不起,沒有回覆你,但我還沒有時間坐下來爲你組裝一個工作代碼。明天我會回覆你的密碼。 :) –