打开网页并保存图像 [英] Open webpage and save image
本文介绍了打开网页并保存图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下VBA代码在IE上打开网站:
I am currently using the following VBA code to open the website on IE:
Set IE = CreateObject("internetexplorer.application")
IE.Visible = True
IE.Navigate "http://test.com"
我现在需要从网站下载一个.gif的图片,它具有以下来源(使用inspect元素):
I now need to download an image from the website as a .gif which has the following source (from using inspect element):
<img src="test.php" align="left">
有什么建议我可以这样做吗?
Any advise on how I could do this please?
推荐答案
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
这篇关于打开网页并保存图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文