将字符串保存到文件:
Open "C:\Users\zdl\Desktop\jingdong\right2.html" For Output As #1
Print #1, txtContent
Close #1
打开网页获取内容:
Set objXML2 = CreateObject("Microsoft.XMLHTTP")
With objXML2
.Open "GET", " http://search.jd.com/Search?keyword=" & unicode & "&enc=utf-8&wq=" & unicode & "&pvid=kj0couei.7qi4c8#keyword=" & unicode & "&enc=utf-8&qrst=1&rt=1&stop=1&vt=2&sttr=1&click=&psort=&page=3", False
' .Open "GET", " http://search.jd.com/Search?keyword=%E8%B8%9D%E9%9D%B4&enc=utf-8&qrst=1&rt=1&stop=1&vt=2&sttr=1&click=&psort=&page=3", False
.send
If objXML2.Status = 200 Then
txtContent2 = .responsetext
jiage = Split(txtContent2, "data-price=" & Chr(34))
For temp = 1 To UBound(jiage)
jiage2 = Split(jiage(temp), Chr(34))
'MsgBox arr4(0)
'GoTo jieshu
Sum = Sum + CCur(jiage2(0))
Next temp
'MsgBox Sum
End If
End With
注意html的大小写问题,还有网站位置可能变化,把获取的网页保存到文件就好了
Open "C:\Users\zdl\Desktop\jingdong\right2.html" For Output As #1
Print #1, txtContent
Close #1
打开网页获取内容:
Set objXML2 = CreateObject("Microsoft.XMLHTTP")
With objXML2
.Open "GET", " http://search.jd.com/Search?keyword=" & unicode & "&enc=utf-8&wq=" & unicode & "&pvid=kj0couei.7qi4c8#keyword=" & unicode & "&enc=utf-8&qrst=1&rt=1&stop=1&vt=2&sttr=1&click=&psort=&page=3", False
' .Open "GET", " http://search.jd.com/Search?keyword=%E8%B8%9D%E9%9D%B4&enc=utf-8&qrst=1&rt=1&stop=1&vt=2&sttr=1&click=&psort=&page=3", False
.send
If objXML2.Status = 200 Then
txtContent2 = .responsetext
jiage = Split(txtContent2, "data-price=" & Chr(34))
For temp = 1 To UBound(jiage)
jiage2 = Split(jiage(temp), Chr(34))
'MsgBox arr4(0)
'GoTo jieshu
Sum = Sum + CCur(jiage2(0))
Next temp
'MsgBox Sum
End If
End With
注意html的大小写问题,还有网站位置可能变化,把获取的网页保存到文件就好了