作者cf1064 (蚵仔)
看板Visual_Basic
標題Re: [.NET] Web Complete沒完整載入網頁的問題
時間Mon Nov 3 23:27:36 2014
Imports System.Threading
Public Class Form1
Dim k = 0 ' 算第幾頁=翻頁次數-1
Dim URL As String
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
URL = "
https://www.google.com/?hl=zh-tw&gws_rd=ssl#hl=zh-tw&q=林書豪&start=0"
WebBrowser1.Navigate(URL)
End Sub
Private Sub WebBrowser1_DocumentCompleted(sender As System.Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
TextBox1.Text = "瀏覽器下載網頁完成 目前翻頁次數=" + k.ToString
Dim a As HtmlElement = Nothing
For Each a In WebBrowser1.Document.All
If a.OuterText IsNot Nothing Then
If a.OuterText.Trim = "下一頁" Then
TextBox2.Text = a.OuterHtml
URL = a.GetAttribute("href")
If URL <> "" Then
k = k + 1 ' 翻頁次數+1
Application.DoEvents()
Thread.Sleep(2000) '等待2秒後進行下一頁
WebBrowser1.Navigate(URL)
WebBrowser1.Refresh()
End If
End If
End If
Next
End Sub
End Class
(一直try連結會被google認為異常流量囧rz...)
附載點:
http://ppt.cc/a3Ic
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.39.183.61
※ 文章網址: http://webptt.com/m.aspx?n=bbs/Visual_Basic/M.1415028458.A.943.html
※ 編輯: cf1064 (114.39.183.61), 11/03/2014 23:32:23