简体   繁体   English

在.NET中的createDocumentFromUrl调用中包括发布变量

[英]Include post variables in a createDocumentFromUrl call in .NET

I have a project in Visual Basic 2010 Express that parses web pages use the IHTMLDocument object. 我在Visual Basic 2010 Express中有一个项目,该项目使用IHTMLDocument对象解析网页。 Here is the function I am using to retrieve a web page: 这是我用来检索网页的功能:

Private Function GetHTML(ByVal url As String)
    Dim htmldoc As New HTMLDocument()
    Dim ihtml2 As IHTMLDocument2
    Dim ihtml3 As IHTMLDocument3
    Dim iPersistStream As IPersistStreamInit

    iPersistStream = DirectCast(htmldoc, IPersistStreamInit)
    iPersistStream.InitNew()

    ihtml2 = htmldoc.createDocumentFromUrl(url, vbNullString)

    Do Until ihtml2.readyState = "complete"
        'required for htmlresult.readyState to transition from "loading" to "complete"
        System.Windows.Forms.Application.DoEvents()
    Loop
    ihtml3 = DirectCast(ihtml2, IHTMLDocument3)

    Return ihtml3
End Function

I'm basically doing stuff like this with the function: 我基本上是用函数来做这样的事情:

ihtml = GetHTML("www.blah.com?getvar1=x&getvar2=y")
ihtml.getElementsByTagName("A")
ihtml.getElementById("myel")
etc, etc...

I'm trying to figure out how I can include POST variables in addition to the URL string when I retrieve the HTML document. 我试图弄清楚在检索HTML文档时如何在URL字符串之外包括POST变量。 By which I mean I'd like to be able to something like this: 我的意思是说我希望能够做到这一点:

ihtml = GetHTML("www.blah.com?getvar1=x&getvar2=y",["postvar1=a","postvar2=b"])

So I'd like to modify my existing GetHTML function in order to allow me to include post variables if that is possible and if not I'd like to know if there is perhaps another way to do this. 因此,我想修改我现有的GetHTML函数,以便在可能的情况下包括post变量,如果不能的话,我想知道是否还有另一种方法可以做到这一点。 Thanks to anyone who can help. 感谢任何能提供帮助的人。

Ok, I would have used WebCilent or WebRequest but... if you're committed to this design: 好的,我会用过WebCilentWebRequest,但是...如果您致力于这种设计:

You have to navigate to the page, find each input field, set the value then call InvokeMember on the button for that page. 您必须导航到页面,找到每个输入字段,设置值,然后在该页面的按钮上调用InvokeMember。 WebBrowser is all about automating a web browser, not so much about making HTTP requests programatically. WebBrowser的全部目的在于使Web浏览器自动化,而不仅仅是以编程方式发出HTTP请求。

Sample code: http://muftisubzero.blogspot.com/2010/12/playing-with-webbrowser-class-cnet.html 示例代码: http : //muftisubzero.blogspot.com/2010/12/playing-with-webbrowser-class-cnet.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在我的项目中包含可执行文件并在.NET中调用它 - How to include an executable with my project and call it in .NET .NET中的Ajax发布调用后下载文件 - Download file after ajax post call in .NET 无法通过.NET中的tinyOauth 1.0a进行POST调用 - Unable to make POST call via tinyOauth 1.0a in .NET 如何将Curl命令转换为.net HttpClient帖子调用 - How to convert Curl command to .net HttpClient post call .NET MVC JSON Post Call响应未完成或成功 - .NET MVC JSON Post Call response does not hit complete or success 生成后.Net程序集检查(属性和调用图) - Post build .Net assembly checking (attributes and call graph) 如何在 .Net 中的 WCF 客户端 Web 服务调用中包含 CDATA 部分? - How do I include a CDATA section in a WCF client webservice call in .Net? .NET自动包含程序集 - .NET Automatic include of assembly 这个方法,我需要从 angular 前端作为 POST 调用它。 在我的 angular 中写下 function 以在 .net 中调用此 post 方法 - This method and I need it to be called from angular frontend as a POST. write that function in my angular to call this post method in .net Angular2 / 4 http POST服务调用.Net / MVC Web API 2.0 REST参数为null - Angular2/4 http POST services call .Net/MVC Web API 2.0 REST parameter is null
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM