利用VB采集部分网页数据
需要采集的页面是:http://ren.baidu.com/uquery/
我想把搜索出来的各用户的ID采集出来,该怎么做。分析了下它的网页源代码,好像是利用json_rs[i].username来保存的。
有示例代码的话就再好不过了
[解决办法]
试试这个
Private Sub Command1_Click()
Dim url As String, p As Long, temp As String, i As Long, n As Long, v() As String
url = "http://ren.baidu.com/uquerys/?type=3&age_from=18&age_to=20&pn="
With CreateObject("Msxml2.XMLHTTP")
Do
p = p + 1
.Open "GET", url & p, False
.send
temp = StrConv(.responsebody, vbUnicode, &H804)
If InStr(temp, "下一页") = 0 Then Exit Do
temp = Split(Split(temp, "s.src=")(2), """")(1)
.Open "geT", temp, False
.send
v = Split(StrConv(.responsebody, vbUnicode, &H804), "username: ")
For i = 1 To UBound(v)
n = n + 1
Debug.Print n; Split(v(i), """")(1)
Next
Debug.Print
Loop
End With
End Sub