本帖最后由 onlycxb 于 2014-10-21 17:05 编辑
-
DongYu作业1.rar
(18.29 KB, 下载次数: 793)
- Sub HomerWork1_1()
- '新手:DongYu
- '作业:1、网站:http://data.bank.hexun.com/lccp/jrxp.aspx
- ' 操作:点击“今日在售产品”,获取今日在售产品第一页的数据。
- Dim xml As New MSXML2.XMLHTTP, url As String, St As String
- Dim arr, brr, ar, i, c
- url = "http://data.bank.hexun.com/lccp/Jrxp.aspx?col=1&tag=desc&date=2014-10-21&page=2"
- With xml
- .Open "GET", url, False
- .send
- St = .responseText
- End With
- St = Split(Split(St, "<div class=""mark"">")(1), "</div>")(0)
- arr = Split(St, "<tr align='center'>")
- ReDim brr(1 To UBound(arr), 1 To 9)
- For i = 1 To UBound(arr)
- ar = arr(i)
- brr(i, 1) = Split(Split(ar, "value='")(1), "'")(0) + Split(Split(ar, "<font class='cred'>")(1), "</font>")(0)
- brr(i, 2) = Split(Split(ar, "</font></td><td class='hl'>")(1), "</td>")(0)
- brr(i, 3) = Split(Split(ar, "<td class='on'>")(1), "</td>")(0)
- brr(i, 4) = Split(Split(ar, "<td class='hl'>")(1), "</td>")(0)
- brr(i, 5) = Split(Split(ar, "<td class='hl'>")(2), "</td>")(0)
- brr(i, 6) = Split(Split(ar, "<td class='hl'>")(3), "</td>")(0)
- brr(i, 7) = Split(Split(ar, "<td class='hl'>")(4), "</td>")(0)
- brr(i, 8) = Split(Split(ar, "<td class='hl'>")(5), "</td>")(0)
- brr(i, 9) = Split(Split(Split(ar, "<td class='hl'>")(5), "</td>")(1), ">")(1)
- Next i
- With ActiveSheet
- .Cells.Clear
- .Columns("D:E").NumberFormatLocal = "yyyy-m-d"
- .[a1].Resize(1, 10) = [{"对比","产品名称","银行","起售日","停售日","币种","管理期(月)","产品类型","预期收益(%)","收益"}]
- .[b2].Resize(UBound(brr, 1), 9) = brr
- End With
- End Sub
复制代码 |