拦截POST数据C#webbrowser winform [英] Intercept POST data C# webbrowser winform

查看:649
本文介绍了拦截POST数据C#webbrowser winform的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试抓一个网页。使用C#和WinForms。我可以将页面加载到WebBrowser中,调用表单的post方法,并获得结果。我想更改日期并重新提交表单。不幸的是,选择日期的控件是一个只读控件,由很多不容易访问的ajax代码(axd文件)驱动。



我以为它会最好在它进入服务器之前尝试拦截POST数据并更改日期字符串。



我似乎无法找到获取帖子的方法数据发送到服务器之前。有没有办法抓住它,修改它,然后发送它的方式?



我尝试过:



 public void CompletedHander(对象发送者,
WebBrowserDocumentCompletedEventArgs e)
{
WebBrowser wb =((WebBrowser)sender);

HtmlElement button = wb.Document.GetElementById(ctl00 $ WebSplitter1 $ tmpl1 $ ContentPlaceHolder1 $ HeaderBTN1 $ btnRetrieve);
if(button!= null)
{
_pushed = true;
button.InvokeMember(click);
}
}

解决方案

WebSplitter1


tmpl1

ContentPlaceHolder1

I am trying to scrape a web page. Using C# and WinForms. I can load the page into a WebBrowser, invoke the post method for a form, and get the results. I'd like to then change the date and resubmit the form. Unfortunately the control for picking the date is a read only control driven by a lot of ajax code (axd files) that aren't easily accessible.

I thought it would be better to try to intercept the POST data before it goes to the server and change the date string.

I can't seem to find a way to get the post data before it is sent to the server. Is there some way to grab it, modify it, and then send it on it's way?

What I have tried:

public void CompletedHander(object sender,
      WebBrowserDocumentCompletedEventArgs e)
{
      WebBrowser wb = ((WebBrowser)sender);

      HtmlElement button = wb.Document.GetElementById("ctl00$WebSplitter1$tmpl1$ContentPlaceHolder1$HeaderBTN1$btnRetrieve");
      if (button != null)
      {
           _pushed = true;
           button.InvokeMember("click");
      }
}

解决方案

WebSplitter1


tmpl1


ContentPlaceHolder1


这篇关于拦截POST数据C#webbrowser winform的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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