''' ‘注意这里的三个单引号
DataTables("头条文章").DataRows.Clear
Dim web As new System.Windows.Forms.WebBrowser
web.Navigate("http://toutiao.com/m6192786832/")
Do Until web.ReadyState = 4
Application.DoEvents
Loop
Do Until web.DocumentText.contains("没有更多啦")
web.Document.Window.ScrollTo(0, 0)
web.Document.Window.ScrollTo(0, web.Document.Body.ScrollRectangle.Height)
Application.DoEvents
Loop
Dim lis = web.Document.GetElementById("content-left").GetElementsByTagName("li")
Dim str As String = ""
For i As Integer = 0 To lis.count-1
Dim dr As DataRow = DataTables("头条文章").AddNew()
Dim lsa = lis(i).GetElementsByTagName("a")
For Each a As object In lsa
If a.GetAttribute("className") = "title-box link" Then
str &= a.InnerHtml & vbcrlf
str &= a.GetAttribute("href") & vbcrlf
dr("网址") = a.GetAttribute("href")
Dim bt As System.Windows.Forms.HtmlElement
bt = web.Document.GetElementByID("keywords") '今日头条单位标题
dr("单位") = bt.innerText & " " & bt.GetAttribute("content")
dr("文章标题") = a.InnerHtml
Exit For
End If
Next
Dim divs = lis(i).GetElementsByTagName("div")
For Each div As object In divs
If div.GetAttribute("className") = "y-left" Then
Dim arr() As String = div.InnerText.Replace(" ","").split("?") ’论坛无法显示这种特殊符号,所以显示成?号了,到网页源码中拷贝这个特殊符号(见下图)到代码编辑器中即可
Dim lsspan As String = arr(0)
dr("阅读数") = lsspan.Replace("阅读","").Replace("播放","")
dr("评论数") = arr(1).Replace("评论","")
dr("发布时间") = arr(2)
Exit For '
End If
Next
Next

此主题相关图片如下:1.png
