|
楼主 |
发表于 2015-3-21 18:43
|
显示全部楼层
- Option Explicit
- Sub test()
- Dim ohttp As Object, strResText As String, URL$, posturl$, postdata$
- Set ohttp = CreateObject("WinHttp.WinHttpRequest.5.1")
- URL = "http://www.boc.cn/sourcedb/whpj/"
- ohttp.Open "GET", URL, False
- ohttp.send
- strResText = ohttp.ResponseText
- strResText = BytesToBstr(ohttp.ResponseBody, "UTF-8")
- PutClipboard (strResText)
- postdata = "erectDate=2015-03-18?hing=2015-03-18&pjname=0"
- posturl = "http://srh.bankofchina.com/search/whpj/search.jsp"
- ohttp.Open "POST", posturl, False
- ohttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
- ohttp.setRequestHeader "Content-Length", Len(postdata)
- ohttp.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko"
- ohttp.setRequestHeader "Referer", "http://www.boc.cn/sourcedb/whpj/"
- ohttp.send (postdata)
- strResText = ohttp.ResponseText
- PutClipboard (strResText)
- End Sub
- Public Sub PutClipboard(ByVal str$)
- With CreateObject("new:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
- .SetText str
- .PutInClipboard
- End With
- 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
-
复制代码 |
|