| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1561 人关注过本帖
标题:POST提交问题。求高手!万分感谢!
只看楼主 加入收藏
yangyao0202
Rank: 1
等 级:新手上路
帖 子:8
专家分:1
注 册:2010-10-2
收藏
 问题点数:0 回复次数:8 
POST提交问题。求高手!万分感谢!
程序。模拟登录,然后模拟发布。比如
比如想用程序在58同城网发布信息。先提交号和密,再提交发布的信息内容。
提交号密现在已经成功了
基本就是"提交动作的RU"L+"?"+"POST参数1&POST参数2&POST参数3……
这里提交账号和密码使用的方法我就不发出来了。是GET提交
this.getpage(" http://my.,cookiecon, 0)
//上面是使用getpage(string,cookiecon,0)  字符串是地址+POST值cookiecon前面有定义  protected static CookieContainer cookiecon;    0是返回的编码为 UTF-8


但是提交发布信息的时候,类型是 multipart/form-data  POST的参数也是这种
/////////////////////////////////////////////////////
----------------------------7da251315905fc
Content-Disposition: form-data; name="commName"

鐧捐姳灏忓尯
-----------------------------7da251315905fc
Content-Disposition: form-data; name="userdefine"


-----------------------------7da251315905fc
Content-Disposition: form-data; name="houseAddr1"

涓滃?鐜?矾
//////////////////////////////////////////////////////
这种应该写成 “commName=鐧捐姳灏忓尯&userdefine=&houseAddr1涓滃?鐜?矾”
用刚才我那个方法提交不成功!。是不是因为request.ContentType = "multipart/form-data"?所以只能用POST提交?

我这里也有POST提交的函数。但是返回字符串是空!函数如下
////////////////////////////////////////////////////////////////////////////////////////////////////////
       public string getpage(string url, string parmList, int type, CookieContainer cc )
   {
         
            HttpWebResponse response = null;
            string str = "";
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method = "POST";
                request.AllowAutoRedirect = false;
                request.KeepAlive = true;
                request.Referer = "http://agent8.
                if (type == 0)
                {
                    request.ContentType = "image/png";
                }
                else if (type == 1)
                {
                    request.ContentType = "application/x-www-form-urlencoded";
                }
                else
                {
                    request.ContentType = "text/html";
                    request.Method = "GET";
                }
                request.CookieContainer=cc;
                byte[] bytes = null;
                if (type == 1)
                {
                    bytes = Encoding.Default.GetBytes(parmList);
                    request.ContentLength = bytes.Length;
                    Stream requestStream = request.GetRequestStream();
                    requestStream.Write(bytes, 0, bytes.Length);
                    requestStream.Close();
                }
                if (type != 0)
                {
                    response = (HttpWebResponse)request.GetResponse();
                    cookieheader = request.CookieContainer.GetCookieHeader(new Uri(url));
                    cc.Add(response.Cookies);
                    Stream responseStream = response.GetResponseStream();
                    Encoding encoding = Encoding.GetEncoding("gb2312");
                    StreamReader reader = new StreamReader(responseStream, encoding);
                    char[] buffer = new char[0x100];
                    for (int i = reader.Read(buffer, 0, 0x100); i > 0; i = reader.Read(buffer, 0, 0x100))
                    {
                        string str2 = new string(buffer, 0, i);
                        str = str + str2;
                    }
                    return str;
                }
                request.ContentLength = 0L;
                response = (HttpWebResponse)request.GetResponse();
                cc.Add(response.Cookies);
                cookieheader = request.CookieContainer.GetCookieHeader(new Uri(url)).ToString();
                Image image = new Bitmap(response.GetResponseStream());
                this.pictureBox1.Image = image;
                return "get verify...";
            }
            catch (Exception exception)
            {
                str = exception.ToString();
            }
            finally
            {
                if (response != null)
                {
                    response.Close();
                }
            }
            return "网络错误";
      }
////////////////////////////////////////////////////////////////////////////////////////////////////////
我把提交的时候抓取的信息也发出来.
提交表单  浏览器提交值到 http://my.
////////////////////////////////////////////////////////////////////////////////////////////////////////
POST /modules/insertprop.ajax.php?rtn=majksell HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/QVOD, application/QVOD, */*
Referer: http://my.
Accept-Language: zh-cn
Content-Type: multipart/form-data; boundary=---------------------------7da251315905fc
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)
Host: my.
Content-Length: 3124
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: sessid=0DC052C7-D0F5-2931-E047-B2038398857A; aQQ_ajkauthinfos=ndGV9RRH%2F4ScNkPFZS%2BRlhLSXtu7K8uBU5IJZ5bosJ3ON7PIOxRktgzLi8eQatgRvVAGotVgHartvNMwRK%2BC7bK%2FIRLICFBCaNk; aQQ_ajkguid=BECB09C6-069A-8369-485D-C9FB5632471B; aQQ_ajklogintime=1287170143; ctid=23; lui=1651510%3A2; aQQ_ajklastuser=yangyao0202; ajk_member_id=1651510; aQQ_ckiprocondnum=0; aQQ_ckinewpm=0; aQQ_ckimarkednum_1651510=0; aQQ_ckimarkednum_1550545=0; aQQ_ckinewpmflg=1; propertys=op8v0-ladfzu_; __utmc=122822679; __utma=122822679.1856445896.1286904626.1287210297.1287212569.16; __utmz=122822679.1287209778.14.8.utmcsr=(referral)|utmcmd=referral|utmcct=/ffb/1.htm; __utmb=122822679.33.10.1287212569

-----------------------------7da251315905fc
Content-Disposition: form-data; name="commName"

鐧捐姳灏忓尯
-----------------------------7da251315905fc
Content-Disposition: form-data; name="userdefine"


-----------------------------7da251315905fc
Content-Disposition: form-data; name="houseAddr1"

涓滃?鐜?矾
-----------------------------7da251315905fc
Content-Disposition: form-data; name="houseAddr2"


-----------------------------7da251315905fc
Content-Disposition: form-data; name="houseAddr3"


-----------------------------7da251315905fc
Content-Disposition: form-data; name="buildArea"

55
-----------------------------7da251315905fc
Content-Disposition: form-data; name="roomNum"

2
-----------------------------7da251315905fc
Content-Disposition: form-data; name="hallNum"

2
-----------------------------7da251315905fc
Content-Disposition: form-data; name="toiletNum"

1
-----------------------------7da251315905fc
Content-Disposition: form-data; name="price"

66
-----------------------------7da251315905fc
Content-Disposition: form-data; name="BuildType"

54
-----------------------------7da251315905fc
Content-Disposition: form-data; name="ProFloor"

3
-----------------------------7da251315905fc
Content-Disposition: form-data; name="FloorNum"

7
-----------------------------7da251315905fc
Content-Disposition: form-data; name="HouseAge"

2000
-----------------------------7da251315905fc
Content-Disposition: form-data; name="fitmentType"

61
-----------------------------7da251315905fc
Content-Disposition: form-data; name="HouseOri"

1
-----------------------------7da251315905fc
Content-Disposition: form-data; name="ProName"

鐧捐姳灏忓尯鏍囬?
-----------------------------7da251315905fc
Content-Disposition: form-data; name="AddExplan"

<p>鐧捐姳灏忓尯鎻忚堪</p>
-----------------------------7da251315905fc
Content-Disposition: form-data; name="uploadcommodelfile"; filename=""
Content-Type: application/octet-stream


-----------------------------7da251315905fc
Content-Disposition: form-data; name="uploadpropertypicfile"; filename=""
Content-Type: application/octet-stream


-----------------------------7da251315905fc
Content-Disposition: form-data; name="uploadcommpicfile"; filename=""
Content-Type: application/octet-stream


-----------------------------7da251315905fc
Content-Disposition: form-data; name="stype"

1
-----------------------------7da251315905fc
Content-Disposition: form-data; name="CommId"

226295
-----------------------------7da251315905fc
Content-Disposition: form-data; name="TradeType"

1
-----------------------------7da251315905fc
Content-Disposition: form-data; name="dataType"

0
-----------------------------7da251315905fc
Content-Disposition: form-data; name="truename"


-----------------------------7da251315905fc
Content-Disposition: form-data; name="hid_ajk_prices"

100000|200000000|700|100000
-----------------------------7da251315905fc
Content-Disposition: form-data; name="hid_brokerid"

375885
-----------------------------7da251315905fc--
////////////////////////////////////////////////////////////////////////////////////////////////////////



搜索更多相关主题的帖子: POST 感谢 
2010-10-16 22:42
yangyao0202
Rank: 1
等 级:新手上路
帖 子:8
专家分:1
注 册:2010-10-2
收藏
得分:0 
希望高手能帮我看看!!谢谢了!!!自己弄了1整天了。。
2010-10-16 22:45
yangyao0202
Rank: 1
等 级:新手上路
帖 子:8
专家分:1
注 册:2010-10-2
收藏
得分:0 
2010-10-18 21:57
yangyao0202
Rank: 1
等 级:新手上路
帖 子:8
专家分:1
注 册:2010-10-2
收藏
得分:0 
怎么还是没人呢
2010-10-25 15:22
wangnannan
Rank: 18Rank: 18Rank: 18Rank: 18Rank: 18
等 级:贵宾
威 望:87
帖 子:2546
专家分:9359
注 册:2007-11-3
收藏
得分:0 
lz 你这是做啥呢 ?

出来混,谁不都要拼命的嘛。 。拼不赢?那就看谁倒霉了。 。有机会也要看谁下手快,快的就能赢,慢。 。狗屎你都抢不到。 。还说什么拼命?
2010-10-25 15:35
yangyao0202
Rank: 1
等 级:新手上路
帖 子:8
专家分:1
注 册:2010-10-2
收藏
得分:0 
模拟提交POST值。。。
2010-10-26 17:55
yangyao0202
Rank: 1
等 级:新手上路
帖 子:8
专家分:1
注 册:2010-10-2
收藏
得分:0 
为什么还没有人帮助我~~~
2010-11-13 11:59
北京的晚秋
Rank: 4
来 自:北京
等 级:业余侠客
帖 子:94
专家分:247
注 册:2010-11-14
收藏
得分:0 
不是不愿意帮,是你真的写的太长了,真没人会抽那么多时间看你写的东西,你就不能精简一点吗

出生在北京的晚秋时节,于是遍爱上了这个季节
2010-11-14 10:35
wawd74520
Rank: 2
等 级:论坛游民
帖 子:4
专家分:25
注 册:2011-12-10
收藏
得分:0 
和58一样。。。中间还有个ajax验证
2011-12-10 14:19
快速回复:POST提交问题。求高手!万分感谢!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028269 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved