18,363
社区成员




Sub ExcelVba_获取论坛上发帖回帖的内容()
Set hf = CreateObject("htmlfile")
Set oDoc = CreateObject("htmlfile")
With CreateObject("Microsoft.XMLHTTP")
.Open "GET", "http://my.csdn.net/hu83369766", False
.send
hf.body.innerhtml = Split(Split(.responsetext, "个人动态</h2>")(1), "</div>")(0)
Set r = hf.all.tags("a")
mm = r(1).href
k = 0
For p = 1 To r.Length - 1 Step 2
.Open "GET", r(p).href, False
.send
oDoc.body.innerhtml = .responsetext
Set s = oDoc.all.tags("table")
For i = 1 To s.Length - 1
If s(i).all.tags("a")(0).href Like "*hu83369766" Then
k = k + 1
Set t = s(i).all.tags("div")
For j = 0 To t.Length - 1
If t(j).classname = "post_body" Then
Cells(k, 1) = r(p).href
Cells(k, 2) = r(p).innertext
Cells(k, 3) = t(j).innertext
End If
Next j
End If
Next i
Next p
End With
End Sub