NO IMAGE

參考(http://blog.csdn.net/hsn1982/archive/2003/04/01/9939.aspx)這篇文章是用VB6寫的,我稍微修改了一下,用在.net2003中,用COM元件,AxWebBrowser就可以實現,程式碼如下(C#)

  Dim Table1 As HTMLTable, Tables As IHTMLElementCollection
        Dim Row As HTMLTableRow, Cell As HTMLTableCell
        Dim Page As Long
        Dim i, j, tmp, Text1, Text2
        Dim fi As New FileInfo(“C:/temp.txt”)
        Dim sw As StreamWriter
        TextBox1.Text = AxWebBrowser1.LocationURL
        Tables = AxWebBrowser1.Document.getElementsByTagName(“Table”)
        For Each Table1 In Tables
            If Microsoft.VisualBasic.Left(Table1.innerText, 4) = “市場概況” Then ‘ 找到需要的Table
                ‘ 將表格轉換成“.csv”格式
                For i = 1 To Table1.rows.length – 1
                    Row = Table1.rows.item(i)
                    j = 0
                    For Each Cell In Row.cells
                        Text1 = Text1 Trim(Row.cells.item(j).innerText) “,”
                        j = j 1
                    Next
                    Text1 = Microsoft.VisualBasic.Left(Text1, Len(Text1) – 1) vbCrLf
                Next

                If fi.Exists = False Then
                    ‘Create a file to write to.
                    sw = fi.CreateText()
                End If
                sw = fi.AppendText()
                sw.WriteLine(Microsoft.VisualBasic.Left(Text1, Len(Text1) – 2))
                Exit For
            End If
        Next
        sw.Close()
除錯的時候經常連不上網,加上這句就OK了

   System.Net.GlobalProxySelection.Select = System.Net.GlobalProxySelection.GetEmptyWebProxy();