|
- Sub t()
- Dim url
- url = "http://chart.cp.360.cn/kaijiang/qxc?lotId=110022&spanType=0&span=" & [e1] & "&r=0.59452286923828"
- Set HTML = CreateObject("htmlfile")
- With CreateObject("msxml2.xmlhttp")
- .Open "get", url, False
- .send
- tt = BytesToBstr(.ResponseBody, "GB2312")
- HTML.body.innerhtml = tt
- End With
- Set tb = HTML.all.tags("table")(1).Rows
- Sheet1.UsedRange.Offset(2).ClearContents
- For i = 2 To tb.Length - 1
- If i >= 2 Then
- Cells(i, 1) = tb(i).Cells(0).innertext
- Cells(i, 2) = tb(i).Cells(1).innertext
- Cells(i, 3) = tb(i).Cells(8).innertext
- End If
- Next
- End Sub
- Function BytesToBstr(strBody, CodeBase) '使用Adodb.Stream对象提取字符串
- Dim objStream
- On Error Resume Next
- Set objStream = CreateObject("Adodb.Stream")
- With objStream
- .Type = 1 '二进制
- .Mode = 3 '读写
- .Open
- .Write strBody '二进制数组写入Adodb.Stream对象内部
- .Position = 0 '位置起始为0
- .Type = 2 '字符串
- .Charset = CodeBase '数据的编码格式
- BytesToBstr = .ReadText '得到字符串
- End With
- objStream.Close
- Set objStream = Nothing
- If Err.Number <> 0 Then BytesToBstr = ""
- On Error GoTo 0
- End Function
复制代码 |
评分
-
1
查看全部评分
-
|