VBA MSXML2.ServerXMLHTTP响应文本是一个HTML页面 [英] VBA MSXML2.ServerXMLHTTP Response text is an HTML Page

查看:1985
本文介绍了VBA MSXML2.ServerXMLHTTP响应文本是一个HTML页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找周围,但我无法找到任何方式做什么,我想在这里做。它可能甚至是不可能的,但我使用MSXML2驱动程序连接到一个网页。响应文本我得到的是网页只是HTML。不正是我一直在寻找,但我也许能与它合作。从那里,我想尝试一个HTML文档对象设置为响应文本,因为它只是一个HTML页面,但我得到一个类型不匹配。我不知道这是否会得到我更接近解决我的问题,但我想这将是值得一问这里。下面是我在做什么:

I've been looking around but I can't find any way to do what I'm trying to do here. It may not even be possible, but I'm using the MSXML2 driver to connect to a web page. The response text I get is just the HTMl of the web page. Not exactly what I was looking for, but I might be able to work with it. From there, I wanted to try to set an HTML document object to that response text, since it is just an HTML page, but I get a type mismatch. I'm not sure if this would get me any closer to a solution to my issue, but I figured it would be worth asking here. Here is what I'm doing:

Sub GetResponseText()
    Dim Document as HTMLDocument
    Dim xmlHTTP As MSXML2.ServerXMLHTTP
    Set xmlHTTP = New MSXML2.ServerXMLHTTP
    xmlHTTP.Open "POST", "http://SomeServerName.dev/SomePage.Aspx", False, "User", "Password"
    xmlHTTP.send "Doesn't matter what I put here, response always the same"
    Set Document = xmlHTTP.responseText   <----- No dice.  Type mismatch here.

所以,正如我说的,我甚至不知道这是否会在所有的工作。想我要办理入住手续。什么,我要做的是这是我试图填写为我工作的公司内部应用程序的概述。我有运气不佳等待AJAX​​完成试图将HTML直接自动化的要求,所以我不知道是否可能像这将有助于。有什么想法?

So, As I was saying, I'm not even sure if this would work at all. Just thought I'd check in. The overview of what I'm trying to do is this is an internal application that I'm trying to fill out for the company I work for. I've had poor luck waiting on AJAX to complete requests trying to automate the HTML directly, so I'm wondering if maybe something like this would help. Any thoughts?

推荐答案

您可以创建一个使用的CreateObject(HTMLFILE) html文件并分配XMLHTTP响应文本。

You can create html document using CreateObject("htmlfile") and assign the xmlhttp response text.

Sub GetResponseText()

    Dim Document As HTMLDocument
    Dim xmlHTTP As MSXML2.ServerXMLHTTP
    Set xmlHTTP = New MSXML2.ServerXMLHTTP
    xmlHTTP.Open "POST", "http://SomeServerName.dev/SomePage.Aspx", False, "User", "Password"
    xmlHTTP.send "Doesn't matter what I put here, response always the same"

    Dim doc As Object
    Set doc = CreateObject("htmlfile")
    doc.body.innerHTML = xmlHTTP.responseText
    debug.print doc.body.innerHTML


End Sub

这篇关于VBA MSXML2.ServerXMLHTTP响应文本是一个HTML页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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