winform模拟至phpwind论坛发帖,提示[非法请求,请返回重试!] 如何处理?

mianrong 2014-01-12 10:38:19


我提交的参数:


string A = "这是第一个帖子";
string B = "这是第一个帖子的内容";//方便起见,一下每个参数隔开
string.Format(";
agicname=;
&magicid=;
&verify=87188a1f;
&cyid=0;
&ajax=1;
&iscontinue=0;
&atc_title={0};
&usernames=;
&atc_tags=;
&atc_money=0;
&atc_rvrc=0;
&replyrewardcredit=money;
&replyreward[replyrewardnum]=;
&replyreward[replyrewardtimes]=;
&replyreward[replyrewardreptimes]=1;
&replyreward[replyrewardchance]=10;
&atc_usesign=1&atc_autourl=1;
&atc_convert=1;
&step=2;
&pid=;
&action=new;
&fid=42;
&tid=0;
&article=0;
&special=0;
&_hexie=7b87286f;
&atc_content={1}", A, B);
string form = Http.PostHtml("http://bbs.eyuyao.com/post.php?fid=42#breadCrumb", post, ref cookie, Encoding.GetEncoding("gb2312"));//提交后提示:非法请求,请返回重试


发帖状态页面:只要填入标题、内容,就直接发帖既可。

atc_content={1} 这个是我自己加上去的,因为在抓包结果上发现,没有内容提交参数。
...全文
549 16 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
lovewangxuan 2015-10-22
  • 打赏
  • 举报
回复
引用 11 楼 mianrong的回复:
不好意思,刚上面的没看到,没注意。 你的方式跟我写的方式差不多。 但是phpwind的post参数不一样。我现在能成功post提交登陆,并且保持coookies,能打开 发帖界面。就是提交帖子的时候,post提交不了,提示非法操作!
可以写一下post合适吗?
seng3018 2014-05-06
  • 打赏
  • 举报
回复
我也是啊 情况一样 怎么解决的啊 !!
qaz952727 2014-04-29
  • 打赏
  • 举报
回复
引用 13 楼 mianrong 的回复:
搞定了。跟post方式无关
楼主怎么搞定的 能说下方法吗,我和楼主的情况一样,
mianrong 2014-01-14
  • 打赏
  • 举报
回复
搞定了。跟post方式无关
mianrong 2014-01-13
  • 打赏
  • 举报
回复
求救~~~~~~~~~~~~~~~~~~~~~~~~~
mianrong 2014-01-13
  • 打赏
  • 举报
回复
有人知道怎么做吗 ?
mianrong 2014-01-13
  • 打赏
  • 举报
回复
顶!!!!!!!!!!!!!!!!!
a12321321321312321 2014-01-13
  • 打赏
  • 举报
回复
引用 11 楼 mianrong 的回复:
不好意思,刚上面的没看到,没注意。 你的方式跟我写的方式差不多。 但是phpwind的post参数不一样。我现在能成功post提交登陆,并且保持coookies,能打开 发帖界面。就是提交帖子的时候,post提交不了,提示非法操作!
哦,没注意。不好意思。你用httpwatch professional看下提交的是什么就知道了。
mianrong 2014-01-13
  • 打赏
  • 举报
回复
不好意思,刚上面的没看到,没注意。 你的方式跟我写的方式差不多。 但是phpwind的post参数不一样。我现在能成功post提交登陆,并且保持coookies,能打开 发帖界面。就是提交帖子的时候,post提交不了,提示非法操作!
mianrong 2014-01-13
  • 打赏
  • 举报
回复
引用 8 楼 f800051235 的回复:
    url = "http://bbs.csdn.net/posts?topic_id=380179890";   string sdsds = SendDataByGET(url, postData, ref cookieContainer);
url = "http://bbs.csdn.net/posts?topic_id=380179890"; string postData = "";//这里的内容怎么写? 你好,这个postData的数据封装格式是什么样子的?
a12321321321312321 2014-01-13
  • 打赏
  • 举报
回复


 #region 同步通过POST方式发送数据
        /// <summary>
        /// 通过POST方式发送数据
        /// </summary>
        /// <param name="Url">url</param>
        /// <param name="postDataStr">Post数据</param>
        /// <param name="cookie">Cookie容器</param>
        /// <returns></returns>
        public static string SendDataByPost(string Url, string postDataStr, ref CookieContainer cookie)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
            if (cookie.Count == 0)
            {
                request.CookieContainer = new CookieContainer();
                cookie = request.CookieContainer;
            }
            else
            {
                request.CookieContainer = cookie;
            }



            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = postDataStr.Length;
            Stream myRequestStream = request.GetRequestStream();
            StreamWriter myStreamWriter = new StreamWriter(myRequestStream, Encoding.GetEncoding("gb2312"));
            myStreamWriter.Write(postDataStr);
            myStreamWriter.Close();

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream myResponseStream = response.GetResponseStream();
            StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
            string retString = myStreamReader.ReadToEnd();
            myStreamReader.Close();
            myResponseStream.Close();

            return retString;
        }
        #endregion

        #region 同步通过GET方式发送数据
        /// <summary>
        /// 通过GET方式发送数据
        /// </summary>
        /// <param name="Url">url</param>
        /// <param name="postDataStr">GET数据</param>
        /// <param name="cookie">GET容器</param>
        /// <returns></returns>
        public static string SendDataByGET(string Url, string postDataStr, ref CookieContainer cookie)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url + (postDataStr == "" ? "" : "?") + postDataStr);
            if (cookie.Count == 0)
            {
                request.CookieContainer = new CookieContainer();
                cookie = request.CookieContainer;
            }
            else
            {
                request.CookieContainer = cookie;
            }

            request.Method = "GET";
            request.ContentType = "application/x-www-form-urlencoded";
            request.Referer = "www.google.com";
              //  "https://passport.csdn.net/account/loginbox?callback=logined&hidethird=1&from=http%3a%2f%2fbbs.csdn.net%2f";
            //request.Headers
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream myResponseStream = response.GetResponseStream();
            StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
            string retString = myStreamReader.ReadToEnd();
            myStreamReader.Close();
            myResponseStream.Close();

            return retString;
        }
        #endregion


a12321321321312321 2014-01-13
  • 打赏
  • 举报
回复
    url = "http://bbs.csdn.net/posts?topic_id=380179890";   string sdsds = SendDataByGET(url, postData, ref cookieContainer);
a12321321321312321 2014-01-13
  • 打赏
  • 举报
回复

       //cookie.Expires = DateTime.Now.AddYears(1);
  

            string url = "https://passport.csdn.net/ajax/accounthandler.ashx";
            string postData = "t=log&u=用户命&p=密码&remember=0&f=b&rand=0.1";
            string loginResult = SendDataByGET(url, postData, ref cookieContainer);

             string aaaaa = UrlEncode("Test Post");
             string postData = "post%5Bbody%5D=" + aaaaa;//+"&commit=%E6%8F%90%E4%BA%A4%E5%9B%9E%E5%A4%8D";

      string sdsds = SendDataByGET(url, postData, ref cookieContainer);
mianrong 2014-01-13
  • 打赏
  • 举报
回复
引用 5 楼 f800051235 的回复:
只用post一个参数就可以了吧。
你好,可以给个例子吗 ? 我现在能在winform下,登陆并打开页面,但是无法提交数据。
a12321321321312321 2014-01-13
  • 打赏
  • 举报
回复
只用post一个参数就可以了吧。
a12321321321312321 2014-01-13
  • 打赏
  • 举报
回复


    [self.textViewContent resignFirstResponder];
    NSString *urlString = [NSString stringWithFormat:@"http://bbs.csdn.net/posts?topic_id=%@",self.topicId];
    ASIFormDataRequest *requestForm = [[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:urlString]];
    requestForm.delegate = self;
    
    
    [requestForm setPostValue:self.textViewContent.text forKey:@"post[body]"];
    [requestForm startAsynchronous];

111,097

社区成员

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

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

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