|
发表于 2016-4-4 08:08
|
显示全部楼层
本楼为最佳答案
整理了下,完整代码如下。。。- Sub main()
- Dim Size As String, result()
- Size = Split(Split(getResponsetext("gid=831&pid=54&size=1"), "total"":")(1), ",")(0)
- InvenstDetail = getResponsetext("gid=831&pid=54&size=" & Size) '后续就是对InvestArr的处理。需要的字段为 bytime ,bytimes, nicname,
- tmp = Split(InvenstDetail, "buyTimes"":")
- ReDim result(Size, 1 To 3)
- For i = 1 To UBound(tmp) '参与人次
- result(i, 3) = Split(tmp(i), ",")(0)
- Next
- tmp = Split(InvenstDetail, "buyTime"":")
- For i = 1 To UBound(tmp) '时间
- result(i, 1) = FROM_UNIXTIME(Split(tmp(i), ",")(0))
- Next
- tmp = Split(InvenstDetail, "nickname"":""") '昵称
- InvenstDetail = ""
- For i = 1 To UBound(tmp)
- result(i, 2) = Split(tmp(i), "")(0)
- Next
- Erase tmp
- result(0, 1) = "时间": result(0, 2) = "昵称": result(0, 3) = "参与人次"
- Cells.Clear
- Range("A1").Resize(UBound(result), 3) = result
- End Sub
- Function getResponsetext(sendStr As String)
- With CreateObject("MSXML2.XMLHTTP")
- .Open "POST", "http://www.ygqq.com/goods/timeline.do?t=0.7006472381931250", False '登录
- .setrequestheader "Referer", "http://www.ygqq.com/goods/goods831-54.html"
- .setrequestheader "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0"
- .setrequestheader "Accept", "application/json, text/javascript, */*; q=0.01"
- .setrequestheader "X-Requested-With", "XMLHttpRequest"
- .setrequestheader "Content-Length", "22"
- .setrequestheader "Host", "www.ygqq.com"
- .setrequestheader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"
- .setrequestheader "Accept-Language", "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3"
- .setrequestheader "Accept-Encoding", "gzip, deflate"
- .send sendStr '获取记录条数
- getResponsetext = .responsetext
- End With
- End Function
- Function FROM_UNIXTIME(UNIXTIME) As String
- FROM_UNIXTIME = Format((UNIXTIME / 1000 + 8 * 3600) / 86400 + 70 * 365 + 19, "yyyy-mm-dd hh:mm:ss:") & Right(UNIXTIME, 3)
- End Function
复制代码 |
评分
-
查看全部评分
|