|
比较忙,先做了个把图片下载到硬盘的
你再照着改吧- Option Explicit
- Sub chaxun()
- Dim xmlhttp As Object
- Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
- xmlhttp.Open "get", "http://mall.taikang.com/elicai/image.jsp?accountid=118201&fundcode=SZ&period=30", False
- xmlhttp.setRequestHeader "Content-Type", "text/html"
- xmlhttp.Send ""
- Do Until xmlhttp.ReadyState = 4
- DoEvents
- Loop
- Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
- xmlhttp.Open "get", "http://mall.taikang.com/elicai/imageServlet", False
- xmlhttp.setRequestHeader "Content-Type", "text/html"
- xmlhttp.Send ""
- Do Until xmlhttp.ReadyState = 4
- DoEvents
- Loop
- If xmlhttp.Status = 200 Then
- ' Debug.Print xmlhttp.responseText
- With CreateObject("ADODB.Stream")
- .Type = 1
- .Open
- .write xmlhttp.Responsebody
- .savetofile ThisWorkbook.Path & "" & "1" & ".jpg", 2 '另存图片
- .Close
- End With
- Else
- reportErr (xmlhttp.Status)
- End If
- End Sub
- Sub reportErr(lStatus As Integer)
- Select Case lStatus
- Case 400
- MsgBox "Bad Request", vbCritical, "连接错误"
- Case 401
- MsgBox "Unauthorized", vbCritical, "连接错误"
- Case 402
- MsgBox "Payment Required", vbCritical, "连接错误"
- Case 403
- MsgBox "Forbidden", vbCritical, "连接错误"
- Case 404
- MsgBox "Not Found", vbCritical, "连接错误"
- Case 407
- MsgBox "Proxy Authentication Required", vbCritical, "连接错误"
- Case 408
- MsgBox "Request Timeout", vbCritical, "连接错误"
- Case 503
- MsgBox "Service Unavailable", vbCritical, "连接错误"
- Case Else
- MsgBox "Can not reach by other reason", vbCritical, "连接错误"
- End Select
- End Sub
复制代码
[ 本帖最后由 xmyjk 于 2011-3-9 21:59 编辑 ] |
|