我目前正在使用以下VBA代码在IE上打开网站:
Set IE = CreateObject("internetexplorer.application")
IE.Visible = True
IE.Navigate "http://test.com"
我现在需要从网站下载一个图像作为.gif,其中包含以下来源(来自使用inspect元素):
<img src="test.php" align="left">
有关我如何做到这一点的任何建议吗?
答案 0 :(得分:0)
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" ( _
ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private Sub Command1_Click()
Dim sin As String
Dim sout As String
Dim ret As Long
sin = "https://upload.wikimedia.org/wikipedia/commons/0/0e/Balle.gif"
sout = Environ("HOMEPATH") & "\Desktop\" & "image.gif"
ret = URLDownloadToFile(0, sin, sout, 0, 0)
If (ret = 0) Then MsgBox "Succedded" Else MsgBox "failed"
End Sub