作者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/cn.aspx?n=bbs/Visual_Basic/M.1415028458.A.943.html
※ 编辑: cf1064 (114.39.183.61), 11/03/2014 23:32:23