|
楼主 |
发表于 2014-10-21 13:56
|
显示全部楼层
本帖最后由 onlycxb 于 2014-10-21 13:58 编辑
分享9- Option Explicit
- Sub 招财宝综合排序数据抓取()
- 'https://zhaocaibao.alipay.com/pf/productList.htm?pfOrderStatus=&pfCurrentPage=210&pfOrderType=&fistView=1
- Dim xml As New MSXML2.XMLHTTP, url$, St$, arr, i%, brr, crr, total%, page%, p%
- Dim rng As Range
- url = "https://zhaocaibao.alipay.com/pf/productList.htm?pfOrderStatus=&pfOrderType=&fistView=1&pfCurrentPage="
- sheet1.cells.clear
- With xml
- .Open "GET", url & "210", False
- .send
- St = .responseText
- total = Split(Split(St, "</span>页")(0), "/")(914) '总数页
- End With
- '页数较多,近两千页,以取前3页为例
- For p = 1 To 3 'total
- With xml
- .Open "GET", url & page, False
- .send
- St = .responseText
- End With
- St = Replace(Replace(St, " ", ""), vbCrLf, "")
- St = Replace(St, "<spanclass=""income-ui-tip"">", "")
- arr = Split(St, "<liclass=""w154"">")
- ReDim brr(1 To UBound(arr) - 2, 1 To 6)
- For i = 2 To UBound(arr) - 1
- brr(i - 1, 1) = Split(arr(i), "<")(0)
- brr(i - 1, 2) = Split(Split(arr(i), "<")(3), ">")(1)
- brr(i - 1, 3) = Split(Split(arr(i), "<")(8), ">")(1)
- brr(i - 1, 4) = Split(Split(arr(i), "<")(10), ">")(1)
- brr(i - 1, 5) = Split(Split(arr(i), "<")(16), ">")(1)
- brr(i - 1, 6) = Replace(Split(Split(arr(i), "<")(20), ">")(1), " ", "")
- Next i
- Set rng = Sheet1.Cells(Rows.Count, 1).End(xlUp)
- rng.Resize(UBound(brr, 1), 6) = brr
- Next p
- End Sub
复制代码 |
|