使用 webBrowser 控件从网络下载图片
我的英语的第一个借口是我来自西班牙。
我有点担心,因为我无法在学校完成我的项目,我正在尝试在 Visual Basic 6 中开发一个应用程序,以使用网络浏览器控件从互联网上释放 CD 封面(专辑艺术),我将此路径放在导航:
“http://www.google.com.co/search? hl=es&safe=active&gbv=2&biw=1280&bih=821&tbm=isch&sa=1&q=%22heroes+del+silencio%22%2B%22avalancha%22%2Balb um+art+small&oq=%22heroes+del+silencio%22%2B%22avalancha%22%2Balbum+art+small&aq=f&aqi=&aql=1&gs_sm=e&gs_upl="
这显示了我需要的封面,但我正在尝试获取第一个图片文件名或 URL 并将其直接保存到我的电脑中的文件夹中,请为我提供一些帮助,谢谢...
我将非常感激你的帮助
First excuse for my English i'm from spain.
I am a little worried because i cannot been able to finish my project in the school, I am trying to develop an application in visual basic 6 to discharge the cd covers (Album Art) from internet using the webbrowser control, i put this path to navigate:
"http://www.google.com.co/search?
hl=es&safe=active&gbv=2&biw=1280&bih=821&tbm=isch&sa=1&q=%22heroes+del+silencio%22%2B%22avalancha%22%2Balbum+art+small&oq=%22heroes+del+silencio%22%2B%22avalancha%22%2Balbum+art+small&aq=f&aqi=&aql=1&gs_sm=e&gs_upl="
This display the covers that I am needing, but i'm trying to get the first Picture filename or URL and save this direct to a Folder In my Pc, please can some help to me, Thanks...
I will be very grateful for your help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经写了一部分代码,你可以继续完成你的程序。
这是 sub 的代码,它为您提供网页的 HTML 代码:
Function GetHTMLCode(strURL As String) As String
Dim objHttp 作为对象,strText 作为字符串
设置 objHttp = CreateObject("MSXML2.ServerXMLHTTP")
objHttp.Open“GET”,strURL,False
objHttp.setRequestHeader“用户代理”,_
“Mozilla/4.0(兼容;MSIE 6.0;Windows NT 5.0)”
objHttp.Send("")
strText = objHttp.responseText
设置 objHttp = Nothing
GetHTMLCode = strText
End Function
我发现 Google 图片中的所有图片链接都是以以下 HTML 代码开头:
src="http://
并以此结束:
”
图片链接就在这两行之间!!!
您可以使用GetHTMLCode 来获取当前网页的所有HTML 代码。
然后使用“instr”函数不断找到这两行,并下载它们之间的链接。
问题解决了!
如果我的回答有用,请投票:)
I have written a part of code and you can continue to finish your program.
This is a code of sub, which gives you HTML Code of web-pages:
Function GetHTMLCode(strURL As String) As String
Dim objHttp As Object, strText As String
Set objHttp = CreateObject("MSXML2.ServerXMLHTTP")
objHttp.Open "GET", strURL, False
objHttp.setRequestHeader "User-Agent", _
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
objHttp.Send ("")
strText = objHttp.responseText
Set objHttp = Nothing
GetHTMLCode = strText
End Function
I have found that all the links of pictures in Google Pictures are starting with this HTML code :
src="http://
and end with this :
"
The links of pictures are between these 2 lines!!!
You can use GetHTMLCode to get all HTML code of current web page.
Then continually find these 2 lines using "instr" function , and download the links between them.
Problem Solved!
Please vote , if my answer is useful :)