VB6下载网页源码 [英] VB6 Download Web Page Source

查看:41
本文介绍了VB6下载网页源码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 VB6 中有没有办法将网页源下载到字符串或文本框?例如,在 VB.Net 中,WebClient 类允许您使用 .DownloadString("google.com") 执行此操作,我如何在 vb6 中执行相同操作?

Is there a way in VB6 to download a web pages source to a string or Textbox? For example in VB.Net the WebClient class allows you to do so using .DownloadString("google.com"), how can I do the same in vb6?

注意:我想避免使用 WebBrowser.

Note: I would like to avoid using a WebBrowser.

推荐答案

我对 VB6 了解不多,但在 VBA...

I don't know much about VB6, but in VBA...

Dim objHttp As Object, strURL as string, strText as string

Set objHttp = CreateObject("MSXML2.ServerXMLHTTP")

strURL = "http://www.yoursite.com/"

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

这篇关于VB6下载网页源码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆