|
本帖最后由 godisboy 于 2018-7-13 17:15 编辑
我的需求就是把提取对应美国亚马逊搜索结果里面的 在线产品总数对应生成的连接没有问题了,但是出来的结果和实际打开的页面里的内容不一样。。。提取出来的数据 ,在对应页面里面压根就找不到,现在完全不知道是怎么回事。。。。跪求大神帮忙看下
https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=adult+tutu这是其中的一个连接,实际页面上是1-36 of over 1,000
而代码出来的 1-48 of over 1,000
小白一枚,就零时学了一下写的,现在完全不懂这是怎么回事。。。跪求解答跪求解答~~~~~
Sub test()
Dim keyword As String
Dim url As String
Dim num As Integer
num = Application.CountA(Sheet1.Range("A:A"))
Dim linkname As String
linkname = "https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords="
Dim i As Integer
For i = 2 To num
keyword = Replace(Sheet1.Range("A" & i), " ", "+")
url = linkname & keyword
ss = getnum(url)
Range("W" & i) = ss
Next
End Sub
Function getnum(ByVal url As String) As String
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", url, False
.send
ss = .responsetext
ss = LCase(ss)
ss = Split(Split(ss, "<span id=""s-result-count"">")(1), "<span>")(0)
ss = Replace(ss, "results for", "")
getnum = ss
End With
End Function
|
|