如何获取网页图片,请高手帮解决,谢谢了
网页代码如下:联系方式:<span class="followMob"><label class='mobile' code="%02%34%18%15%0A%17%04%1A%36%00%19%24%31%39%0F%0E%1D%11%21%34%22%07" src="http://static.baixing.net/pages/mobile.php?c=%02%34%18%15%0A%17%04%1A%36%00%19%24%31%39%0F%0E%1D%11%21%34%22%07/3.jpg"></label>
请高手,劳烦一下,帮代码写出来,本人新手,,,谢谢了,,,只要获取图片地址就行了。。。谢谢啦 直接从网页代码中读取http://static.baixing.net/pages/mobile.php?c=%02%34%18%15%0A%17%04%1A%36%00%19%24%31%39%0F%0E%1D%11%21%34%22%07/3.jpg就好了~~~ 每次的图片地址是不一样的,,, '此代码由“正则测试工具 v1.1.35”自动生成,请直接调用TestReg过程
Private Sub TestReg()
Dim strData As String
Dim reg As Object
Dim matchs As Object, match As Object
strData = "联系方式:<span class=""followMob""><label class='mobile' code=""%02%34%18%15%0A%17%04%1A%36%00%19%24%31%39%0F%0E%1D%11%21%34%22%07"" src=""http://static.baixing.net/pages/mobile.php?c=%02%34%18%15%0A%17%04%1A%36%00%19%24%31%39%0F%0E%1D%11%21%34%22%07/3.jpg""></label> "
Set reg = CreateObject("vbscript.regExp")
reg.Global = True
reg.IgnoreCase = True
reg.MultiLine = True
reg.Pattern = "class=""followMob"">.*?src=""(.+?)"""
Set matchs = reg.Execute(strData)
For Each match In matchs
'Debug.Print match.Value
Debug.Print match.SubMatches(0)
Next
End Sub
With XMLHTTP60里面有固定格式的。先找到Img 再就是SRC后就是了
'可设置 异步 True 同步 False
.open "GET", "http://www.XXX.com/3.jpg" & Path, True
'异步通知回调函数
.onreadystatechange = AEF '回调函数 默认函数
.send
'也可以使用同步 把AEF函数出来步骤放在下面
End With
function AEF()
Dim ADOStream As ADODB.Stream
Dim fso As Scripting.FileSystemObject
'判读是否正确请求
if XMLHTTP60.readyState <> 4 then exit function
'接收数据
if XMLHTTP60.Status=200 then
'数据下载完毕
Set ADOStream = New ADODB.Stream
Set fso = New Scripting.FileSystemObject
ADOStream .Type = adTypeBinary
ADOStream .open
ADOStream .Write XMLHTTP60.responseBody
ADOStream.SaveToFile "X:\XXX.jpg", adSaveCreateOverWrite
ADOStream.Close
else
'Error
end if
end function
'网页图片地址截取 这个出来方式很多 比如
X1=Instr(1,"样本","Src=")
X2=Instr(1,"样本",".jpg")
ImageSrc=mid("样本",X1+4,X2-X1) '+4 为 Src= 之后才是图片地址跳过 Src=
补充:VB , 基础类