需要以某種方式將每個季節的季節和劇集數量從維基百科表格複製到兩個組合框中。一個是季節,另一個是情節。應用程序應該允許用戶在頂部輸入框中輸入他們偏愛的節目。 然後隨季節的數量填充第一組合框和當用戶選擇一個事件的相關數目被示如何將維基百科表中的信息複製到組合框? Visual Basic.Net
鏈接表,在每個季節的季節的數目和發作次數: http://en.wikipedia.org/wiki/List_of_House_episodes#Series_overview_and_ratings
代碼:
Public Class Form1
Dim Search As String
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Search = TextBox1.Text
Search = Search.Replace(" ", "+")
Search = "http://www.google.com/search?btnI=I'm+Feeling+Lucky&q=" & Search & "episode+list+wikipedia"
If Asc(e.KeyChar) = 13 Then
WebBrowser1.Navigate(Search)
TextBox1.Text = Search
End If
End Sub
End Class
到目前爲止,我已經找到了HOWTO下載網頁的源文件,甚至操縱頁面一點,但我不知道如何使用它來獲取季節發作的次數在每個賽季打入組合框。任何幫助將是巨大的感謝
代碼:
Imports System.Text.RegularExpressions
Public Class Form1
Dim sourcecode As String
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
sourcecode = ((New Net.WebClient).DownloadString("http://en.wikipedia.org/wiki/List_of_House_episodes#Series_overview_and_ratings "))
Dim Code As String
Dim Information As MatchCollection = Regex.Matches(sourcecode, "<td>(.*?)</td>", RegexOptions.None)
For Each Info In Information
Code = Regex.Replace(Info.ToString, "td>", "", RegexOptions.None)
Code = Regex.Replace(Code, "</td>", "", RegexOptions.None)
MsgBox(Code)
Next
End Sub
End Class
看看HtmlAgilityPack。 –