问题描述
小弟今天弄个类似httpcatch的小插件,获取网页提交的post数据,但是总是不全,我只实验了我自己的网站。获取信息如下-----------------------------7dfc72530740Content-Disposition:form-data;name="channelid"1-----------------------------7dfc72530740Content-Disposition:form-data;name="dopost"save-----------------------------7dfc72530740Content-Disposition:form-data;name="title"fdsfdsfsdf123-----------------------------7dfc72530740Content-Disposition:form-data;name="shorttitle"-----------------------------7dfc72530740Content-Disposition:form-data;name="redirecturl"-----------------------------7dfc72530740Content-Disposition:form-data;name="tags"-----------------------------7dfc72530740Content-Disposition:form-data;name="weight"35-----------------------------7dfc72530740Content-Disposition:form-data;name="picname"-----------------------------7dfc72530740Content-Disposition:form-data;name="litpic";filename=""Content-Type:application/octet-stream
而用搜狗浏览器的开发工具获取全了,如下------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="channelid"1------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="dopost"save------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="title"ddddddddddddddd------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="shorttitle"------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="redirecturl"------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="tags"------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="weight"18------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="picname"------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="litpic";filename=""Content-Type:application/octet-stream------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="source"------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="writer"------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="typeid"4------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="typeid2"------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="keywords"------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="autokey"1------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="description"------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="dede_addonfields"------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="remote"1------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="autolitpic"1------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="needwatermark"1------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="sptype"hand------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="spsize"5------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="body"ddddddddddddddddddd------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="voteid"------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="notpost"0------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="click"79------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="sortup"0------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="color"------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="arcrank"0------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="money"0------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="pubdate"2015-01-2016:00:00------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="ishtml"1------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="filename"------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="templet"------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="imageField.x"26------WebKitFormBoundaryLPUllvHBy3ZImlBcContent-Disposition:form-data;name="imageField.y"15------WebKitFormBoundaryLPUllvHBy3ZImlBc--
所以看出获取少了,下面是主要代码,请高手指点privatevoidGoUrl(){stringurl=this.txtUrl.Text;SHDocVw.WebBrowserwb=CreateNewWebBrowser();//Returnifnowheretogoif(url=="")return;try{Cursor.Current=Cursors.WaitCursor;Objecto=null;wb.Navigate(url,refo,refo,refo,refo);}finally{inti=this.txtUrl.Items.IndexOf(url);if(i==-1)this.txtUrl.Items.Add(url);Cursor.Current=Cursors.Default;}}privatevoidwb_DocumentComplete(objectpDisp,refobjectURL){SHDocVw.WebBrowserwb=(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();}privatevoidwb_ProgressChange(intProgress,intProgressMax){this.toolStripProgressBar1.Visible=true;SHDocVw.WebBrowserwb=(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();}elseif(wb.ReadyState==SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE){this.toolStripProgressBar1.Value=0;this.toolStripProgressBar1.Visible=false;}}privatevoidwb_StatusTextChange(stringText){this.toolStripStatusLabel1.Text=Text;//Application.DoEvents();}privatevoidwb_NewWindow2(refobjectppDisp,refboolCancel){SHDocVw.WebBrowser_axWebBrowser=CreateNewWebBrowser();ppDisp=_axWebBrowser.Application;_axWebBrowser.RegisterAsBrowser=true;}privatevoidwb_BeforeNavigate2(objectpDisp,refobjectURL,refobjectFlags,refobjectTargetFrameName,refobjectPostData,refobjectHeaders,refboolCancel){stringy=System.Text.Encoding.ASCII.GetString(PostDataasbyte[]);intl=y.Length;byte[]byArr=System.Text.Encoding.ASCII.GetBytes(y);this.textBox2.Text="提交地址:"+URL.ToString()+"ntr"+y;this.textBox1.Text=((System.Windows.Forms.WebBrowser)this.WebBrowserTab.TabPages[0].Controls[0]).Document.Cookie.ToString();}privateSHDocVw.WebBrowserCreateNewWebBrowser(){this.toolSource.Enabled=true;System.Windows.Forms.WebBrowserTmpWebBrowser=newSystem.Windows.Forms.WebBrowser();this.WebBrowserTab.TabPages[0].Controls.Add(TmpWebBrowser);TmpWebBrowser.Dock=DockStyle.Fill;SHDocVw.WebBrowserwb=(SHDocVw.WebBrowser)TmpWebBrowser.ActiveXInstance;wb.CommandStateChange+=newSHDocVw.DWebBrowserEvents2_CommandStateChangeEventHandler(this.wb_CommandStateChange);wb.BeforeNavigate2+=newSHDocVw.DWebBrowserEvents2_BeforeNavigate2EventHandler(this.wb_BeforeNavigate2);wb.ProgressChange+=newSHDocVw.DWebBrowserEvents2_ProgressChangeEventHandler(this.wb_ProgressChange);wb.StatusTextChange+=newSHDocVw.DWebBrowserEvents2_StatusTextChangeEventHandler(this.wb_StatusTextChange);wb.NavigateError+=newSHDocVw.DWebBrowserEvents2_NavigateErrorEventHandler(this.wb_NavigateError);wb.NavigateComplete2+=newSHDocVw.DWebBrowserEvents2_NavigateComplete2EventHandler(this.wb_NavigateComplete2);wb.TitleChange+=newSHDocVw.DWebBrowserEvents2_TitleChangeEventHandler(this.wb_TitleChange);wb.DocumentComplete+=newSHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler(this.wb_DocumentComplete);wb.NewWindow2+=newSHDocVw.DWebBrowserEvents2_NewWindow2EventHandler(this.wb_NewWindow2);returnwb;}privatevoidwb_CommandStateChange(intCommand,boolEnable){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;}}privatevoidwb_NavigateError(objectpDisp,refobjectURL,refobjectFrame,refobjectStatusCode,refboolCancel){}
解决方案
解决方案二:
在线坐等大神
解决方案三:
没人?。。。。。。。。。。。。。。。。。。。。自己顶