使用 SHDocVw.WebBrowser获取post数据不全 是怎么个情况 求高手解答

zqb1987 2015-01-21 01:34:23
小弟今天弄个类似httpcatch的小插件,获取网页提交的post数据,但是总是不全,我只实验了我自己的网站。获取信息如下


-----------------------------7dfc72530740
Content-Disposition: form-data; name="channelid"
1
-----------------------------7dfc72530740
Content-Disposition: form-data; name="dopost"
save
-----------------------------7dfc72530740
Content-Disposition: form-data; name="title"
fdsfdsfsdf123
-----------------------------7dfc72530740
Content-Disposition: form-data; name="shorttitle"
-----------------------------7dfc72530740
Content-Disposition: form-data; name="redirecturl"
-----------------------------7dfc72530740
Content-Disposition: form-data; name="tags"
-----------------------------7dfc72530740
Content-Disposition: form-data; name="weight"
35
-----------------------------7dfc72530740
Content-Disposition: form-data; name="picname"
-----------------------------7dfc72530740
Content-Disposition: form-data; name="litpic"; filename=""
Content-Type: application/octet-stream

而用搜狗浏览器的开发工具 获取全了,如下

------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="channelid"

1
------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="dopost"

save
------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="title"

ddddddddddddddd
------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="shorttitle"


------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="redirecturl"


------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="tags"


------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="weight"

18
------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="picname"


------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="litpic"; filename=""
Content-Type: application/octet-stream


------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="source"


------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="writer"


------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="typeid"

4
------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="typeid2"


------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="keywords"


------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="autokey"

1
------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="description"


------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="dede_addonfields"


------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="remote"

1
------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="autolitpic"

1
------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="needwatermark"

1
------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="sptype"

hand
------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="spsize"

5
------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="body"

ddddddddddddddddddd
------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="voteid"


------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="notpost"

0
------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="click"

79
------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="sortup"

0
------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="color"


------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="arcrank"

0
------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="money"

0
------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="pubdate"

2015-01-20 16:00:00
------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="ishtml"

1
------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="filename"


------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="templet"


------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="imageField.x"

26
------WebKitFormBoundaryLPUllvHBy3ZImlBc
Content-Disposition: form-data; name="imageField.y"

15
------WebKitFormBoundaryLPUllvHBy3ZImlBc--

所以看出获取少了,下面是主要代码,请高手指点
 private void GoUrl()
{
string url = this.txtUrl.Text;

SHDocVw.WebBrowser wb = CreateNewWebBrowser();


// Return if nowhere to go
if (url == "")
return;

try
{
Cursor.Current = Cursors.WaitCursor;
Object o = null;
wb.Navigate(url, ref o, ref o, ref o, ref o);
}
finally
{
int i = this.txtUrl.Items.IndexOf(url);
if (i == -1)
this.txtUrl.Items.Add(url);

Cursor.Current = Cursors.Default;
}
}

private void wb_DocumentComplete(object pDisp, ref object URL)
{
SHDocVw.WebBrowser wb = (SHDocVw.WebBrowser)((System.Windows.Forms.WebBrowser)this.WebBrowserTab.TabPages[0].Controls[0]).ActiveXInstance;

if (wb.ReadyState == SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
{

this.txtUrl.Text = wb.LocationURL;


this.toolStripProgressBar1.Value = 0;
this.toolStripProgressBar1.Visible = false;

}

this.textBox1.Text = ((System.Windows.Forms.WebBrowser)this.WebBrowserTab.TabPages[0].Controls[0]).Document.Cookie.ToString();

}

private void wb_ProgressChange(int Progress, int ProgressMax)
{
this.toolStripProgressBar1.Visible = true;

SHDocVw.WebBrowser wb = (SHDocVw.WebBrowser)((System.Windows.Forms.WebBrowser)this.WebBrowserTab.TabPages[0].Controls[0]).ActiveXInstance;

if ((Progress > 0) && (ProgressMax > 0))
{
this.toolStripProgressBar1.Maximum = ProgressMax;
this.toolStripProgressBar1.Step = Progress;
this.toolStripProgressBar1.PerformStep();
}
else if (wb.ReadyState == SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
{
this.toolStripProgressBar1.Value = 0;
this.toolStripProgressBar1.Visible = false;
}
}

private void wb_StatusTextChange(string Text)
{
this.toolStripStatusLabel1.Text = Text;
//Application.DoEvents();

}
private void wb_NewWindow2(ref object ppDisp, ref bool Cancel)
{
SHDocVw.WebBrowser _axWebBrowser = CreateNewWebBrowser();
ppDisp = _axWebBrowser.Application;
_axWebBrowser.RegisterAsBrowser = true;
}

private void wb_BeforeNavigate2(object pDisp, ref object URL, ref object Flags, ref object TargetFrameName, ref object PostData, ref object Headers, ref bool Cancel)
{
string y = System.Text.Encoding.ASCII.GetString(PostData as byte[]);
int l=y.Length;
byte[] byArr = System.Text.Encoding.ASCII.GetBytes(y);
this.textBox2.Text = "提交地址:" + URL.ToString() + " \n\t\r" +y;

this.textBox1.Text = ((System.Windows.Forms.WebBrowser)this.WebBrowserTab.TabPages[0].Controls[0]).Document.Cookie.ToString();
}
private SHDocVw.WebBrowser CreateNewWebBrowser()
{
this.toolSource.Enabled = true;
System.Windows.Forms.WebBrowser TmpWebBrowser = new System.Windows.Forms.WebBrowser();
this.WebBrowserTab.TabPages[0].Controls.Add(TmpWebBrowser);
TmpWebBrowser.Dock = DockStyle.Fill;
SHDocVw.WebBrowser wb = (SHDocVw.WebBrowser)TmpWebBrowser.ActiveXInstance;
wb.CommandStateChange += new SHDocVw.DWebBrowserEvents2_CommandStateChangeEventHandler(this.wb_CommandStateChange);
wb.BeforeNavigate2 += new SHDocVw.DWebBrowserEvents2_BeforeNavigate2EventHandler(this.wb_BeforeNavigate2);
wb.ProgressChange += new SHDocVw.DWebBrowserEvents2_ProgressChangeEventHandler(this.wb_ProgressChange);
wb.StatusTextChange += new SHDocVw.DWebBrowserEvents2_StatusTextChangeEventHandler(this.wb_StatusTextChange);
wb.NavigateError += new SHDocVw.DWebBrowserEvents2_NavigateErrorEventHandler(this.wb_NavigateError);
wb.NavigateComplete2 += new SHDocVw.DWebBrowserEvents2_NavigateComplete2EventHandler(this.wb_NavigateComplete2);
wb.TitleChange += new SHDocVw.DWebBrowserEvents2_TitleChangeEventHandler(this.wb_TitleChange);
wb.DocumentComplete += new SHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler(this.wb_DocumentComplete);
wb.NewWindow2 += new SHDocVw.DWebBrowserEvents2_NewWindow2EventHandler(this.wb_NewWindow2);
return wb;
}
private void wb_CommandStateChange(int Command, bool Enable)
{ switch (Command) {
case ((int)CommandStateChangeConstants.CSC_NAVIGATEFORWARD):
this.toolNext.Enabled = Enable;
this.menuNext.Enabled = Enable;
break;
case ((int)CommandStateChangeConstants.CSC_NAVIGATEBACK):
this.toolBack.Enabled = Enable;
this.menuBack.Enabled = Enable;
break;
default:
break; } }
private void wb_NavigateError(object pDisp, ref object URL, ref object Frame, ref object StatusCode, ref bool Cancel)
{
}
...全文
273 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
大哥 这个问题你解决了吗
zqb1987 2015-01-21
  • 打赏
  • 举报
回复
没人?。。。。。。。。。。。。。。。。。。。。自己顶
zqb1987 2015-01-21
  • 打赏
  • 举报
回复
在线坐等大神

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧