1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
Dim webStream As Stream
Dim req As HttpWebRequest
Dim res As HttpWebResponse
WebResponse.Text = ""
If WebAddress.Text = "" Then
MessageBox.Show("Enter a web address!")
Exit Sub
End If
Try
req = CType(WebRequest.Create(WebAddress.Text), HttpWebRequest)
req.Method = "GET" ' Method of sending HTTP Request(GET/POST)
res = CType(req.GetResponse(), HttpWebResponse) ' Send Request
webStream = res.GetResponseStream() ' Get Response
Dim SR As New StreamReader(webStream)
Dim Doc As IHTMLDocument2
Doc = New HTMLDocumentClass ' mshtml properties Embeded Interop type must be set to FALSE
Doc.write(SR.ReadToEnd())
webStream.Close()
Dim sb As New Text.StringBuilder
For i As Integer = 0 To Doc.all.length - 1
Dim hElm As IHTMLElement = DirectCast(Doc.all.item(i), IHTMLElement)
If hElm.innerText <> "" Then
If InStrRev(hElm.innerText, "tabledata1", Microsoft.VisualBasic.CompareMethod.Text) > 0 Then
sb.Append(hElm.innerText & vbCrLf)
End If
End If
sb.Append(i.ToString & vbCrLf)
Next
Doc.close()
WebResponse.Text = sb.ToString
Catch ex As Exception
WebResponse.Text = ex.ToString
End Try |
Partager