| 广告联系 | 繁体版 | 手机版 | 微信 | 微博 | 搜索:
欢迎您 游客 | 登录 | 免费注册 | 忘记了密码 | 社交账号注册或登录

首页

新闻资讯

论坛

温哥华地产

大温餐馆点评

温哥华汽车

温哥华教育

黄页/二手

旅游
搜索:  

 论坛通告:  转载新闻请务必注明出处,这些媒体请不要转,谢谢   请不要上传第三方有版权的照片,请尊重版权,谢谢   批评商家需要注意  
 个人空间: 乱想 | XY | 湖里湖涂 | 血流成河 | 顾晓军 | 罗蓬特机器人 | 白龙王许道长 | 我的退休生活 | Amy Yi | 客观中立而实事求是,唯服理据而杜绝辱骂 | 快乐的狮子 | 我在温哥华 | 忽然听到一個墨西哥女仔唱。呐呐呐呐呐呢呐 | 滄海一聲笑 | NotmeL8 | little fish in the sky | 一袭绛襦落鹏城,九天玄女下凡间。 | 真情Z下海 | xian | nessus
 最新求助: 请问谁知道哪里有卖理发的电动推子?   忽然有个疑问:战争时期,加拿大拿PR卡未入籍的永久居民会被强制服兵役吗?   这个银条   如何修改会员名?
 论坛转跳:
     发帖回帖获取加西镑, 兑换精彩礼物

论坛首页 -> IT人生

Contribute some source code here ... (发表于9年前)

分页: 1, 2, 3, 4  下一页  



回复主题  图片幻灯展示  增添帖子到书签中  给帖子中的发贴者批量赠送献花或者花篮    |##| -> |=|        发表新主题
阅读上一个主题 :: 阅读下一个主题  
作者 正文
webdriver
(只看此人)




文章 时间: 2014-9-24 11:15 引用回复
Only if you know what's the meaning ... google is your friend icon_wink.gif

代码:


        public static string HTTP_POST(string Url, string Data, string Cookie, string ContentType)
        {
            string Out = String.Empty;
            System.Net.HttpWebRequest req = System.Net.HttpWebRequest.Create(Url) as System.Net.HttpWebRequest;
            try
            {
                req.Method = "POST";
                req.Timeout = 100000;
                req.ContentType = ContentType; //something like "multipart/form-data; boundary= xxxxxxxxxxx";
                req.UserAgent = "Safari/537.36";
                req.CookieContainer = new CookieContainer();
                req.CookieContainer.Add(new Uri("http://www.google.com"), GetCookieCollectionFromCookieString(Cookie));  // <-- replace the Uri of your own target
                req.Headers.Add("Accept-Encoding", "gzip,deflate");
                req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
                req.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
               
                byte[] sentData = Encoding.UTF8.GetBytes(Data);  // <-- change your encoding if you want to publish different content
                req.ContentLength = sentData.Length;
                using (System.IO.Stream sendStream = req.GetRequestStream())
                {
                    sendStream.Write(sentData, 0, sentData.Length);
                    sendStream.Close();
                }
               
                System.Net.WebResponse res = req.GetResponse();
                System.IO.Stream ReceiveStream = res.GetResponseStream();
                using (System.IO.StreamReader sr = new System.IO.StreamReader(ReceiveStream, Encoding.UTF8))  //<-- change encoding if you know the website's encoding method
                {
                    Char[] read = new Char[256];
                    int count = sr.Read(read, 0, 256);

                    while (count > 0)
                    {
                        String str = new String(read, 0, count);
                        Out += str;
                        count = sr.Read(read, 0, 256);
                    }
                }
            }
            catch (ArgumentException ex)
            {
                Out = string.Format("HTTP_ERROR :: The second HttpWebRequest object has raised an Argument Exception as 'Connection' Property is set to 'Close' :: {0}", ex.Message);
            }
            catch (WebException ex)
            {
                Out = string.Format("HTTP_ERROR :: WebException raised! :: {0}", ex.Message);
            }
            catch (Exception ex)
            {
                Out = string.Format("HTTP_ERROR :: Exception raised! :: {0}", ex.Message);
            }

            return Out;
        }

        private static CookieCollection GetCookieCollectionFromCookieString(string Cookie)
        {
            CookieCollection cl = new CookieCollection();

            string[] pp = Cookie.Split('=',';');

            for(int i = 0; i<pp.Length;)
            {
                Cookie ck = new Cookie(pp[i].Trim(), pp[i + 1].Trim());
                cl.Add(ck);
                i += 2;
            }

            return cl;
        }

 
花篮
分享
_________________
There is no wisdom tree; nor a stand of a mirror bright, Since all is void, where can the dust alight?


上一次由webdriver于2014-9-28 22:16修改,总共修改了4次
楼主 | 电梯直达
阅读会员资料 发送站内短信 主题 User photo gallery 礼物  
webdriver
(只看此人)




文章 时间: 2014-9-24 11:16 引用回复
老大动作很快嘛,现在发这个主贴都没棒棒,非逼着偶用带着中文输入的电脑啊????
 
花篮
分享
_________________
There is no wisdom tree; nor a stand of a mirror bright, Since all is void, where can the dust alight?
沙发 | 返回顶端
阅读会员资料 发送站内短信 主题 User photo gallery 礼物  
callmelxylt
(只看此人)



文章 时间: 2014-9-24 11:18 引用回复
webdriver 写道:
Only if you know what's the meaning ... google is your friend icon_wink.gif

代码:


        public static string HTTP_POST(string Url, string Data, string Cookie, string ContentType)
        {
            string Out = String.Empty;
            System.Net.HttpWebRequest req = System.Net.HttpWebRequest.Create(Url) as System.Net.HttpWebRequest;
            try
            {
                req.Method = "POST";
                req.Timeout = 100000;
                req.ContentType = ContentType; //something like "multipart/form-data; boundary= xxxxxxxxxxx";
                req.UserAgent = "Safari/537.36";
                req.CookieContainer = new CookieContainer();
                req.CookieContainer.Add(new Uri("http://www.google.com"), GetCookieCollectionFromCookieString(Cookie));
               
                byte[] sentData = Encoding.UTF8.GetBytes(Data);
                req.ContentLength = sentData.Length;
                using (System.IO.Stream sendStream = req.GetRequestStream())
                {
                    sendStream.Write(sentData, 0, sentData.Length);
                    sendStream.Close();
                }
                System.Net.WebResponse res = req.GetResponse();
                System.IO.Stream ReceiveStream = res.GetResponseStream();
                using (System.IO.StreamReader sr = new System.IO.StreamReader(ReceiveStream, Encoding.UTF8))
                {
                    Char[] read = new Char[256];
                    int count = sr.Read(read, 0, 256);

                    while (count > 0)
                    {
                        String str = new String(read, 0, count);
                        Out += str;
                        count = sr.Read(read, 0, 256);
                    }
                }
            }
            catch (ArgumentException ex)
            {
                Out = string.Format("HTTP_ERROR :: The second HttpWebRequest object has raised an Argument Exception as 'Connection' Property is set to 'Close' :: {0}", ex.Message);
            }
            catch (WebException ex)
            {
                Out = string.Format("HTTP_ERROR :: WebException raised! :: {0}", ex.Message);
            }
            catch (Exception ex)
            {
                Out = string.Format("HTTP_ERROR :: Exception raised! :: {0}", ex.Message);
            }

            return Out;
        }

        private static CookieCollection GetCookieCollectionFromCookieString(string Cookie)
        {
            CookieCollection cl = new CookieCollection();

            string[] pp = Cookie.Split('=',';');

            for(int i = 0; i<pp.Length;)
            {
                Cookie ck = new Cookie(pp[i].Trim(), pp[i + 1].Trim());
                cl.Add(ck);
                i += 2;
            }

            return cl;
        }



Thanks for sharing
 
花篮
分享
板凳 | 返回顶端
阅读会员资料 发送站内短信 主题 User photo gallery 礼物  
飞舞的音符
(只看此人)



文章 时间: 2014-9-24 11:18 引用回复
现在主贴没棒了?还是只有英文就没棒?
 
花篮
分享
地板 | 返回顶端
阅读会员资料 发送站内短信 主题 User photo gallery 礼物  
webdriver
(只看此人)



文章 时间: 2014-9-24 11:19 引用回复
callmelxylt 写道:
Thanks for sharing


you are very welcome 。。。(要有中文)
 
花篮
分享
_________________
There is no wisdom tree; nor a stand of a mirror bright, Since all is void, where can the dust alight?
5 楼 | 返回顶端
阅读会员资料 发送站内短信 主题 User photo gallery 礼物  
小闪
(只看此人)



文章 时间: 2014-9-24 11:19 引用回复
dingfenzuoan,niya
 
花篮
分享
6 楼 | 返回顶端
阅读会员资料 发送站内短信 主题 User photo gallery 礼物  
callmelxylt
(只看此人)



文章 时间: 2014-9-24 11:19 引用回复
飞舞的音符 写道:
现在主贴没棒了?还是只有英文就没棒?


test test test
 
花篮
分享
7 楼 | 返回顶端
阅读会员资料 发送站内短信 主题 User photo gallery 礼物  
webdriver
(只看此人)



文章 时间: 2014-9-24 11:20 引用回复
小闪 写道:
dingfenzuoan,niya


没啥,帮老大做测试。。。免费,呵呵
 
花篮
分享
_________________
There is no wisdom tree; nor a stand of a mirror bright, Since all is void, where can the dust alight?
8 楼 | 返回顶端
阅读会员资料 发送站内短信 主题 User photo gallery 礼物  
飞舞的音符
(只看此人)



文章 时间: 2014-9-24 11:20 引用回复
callmelxylt 写道:
test test test


哈哈,结果怎样?
 
花篮
分享
9 楼 | 返回顶端
阅读会员资料 发送站内短信 主题 User photo gallery 礼物  
callmelxylt
(只看此人)



文章 时间: 2014-9-24 11:20 引用回复
小闪 写道:
dingfenzuoan,niya


(要有中文)...
 
花篮
分享
10 楼 | 返回顶端
阅读会员资料 发送站内短信 主题 User photo gallery 礼物  
 
回复主题     |##| -> |=|     论坛首页 -> IT人生 所有的时间均为 美国太平洋时间
1页,共4 分页: 1, 2, 3, 4  下一页  


注:
  • 以上论坛所有发言仅代表发帖者个人观点, 并不代表本站观点或立场, 加西网对此不负任何责任。
  • 投资理财及买房卖房版面的帖子不构成投资建议。投资有风险,责任请自负
  • 对二手买卖中的虚假信息,买卖中的纠纷等均与本站无关。
  • 黄页热门商家 免费个人广告
    发布商业广告

    不能在本论坛发表新主题
    不能在本论坛回复主题
    不能在本论坛编辑自己的文章
    不能在本论坛删除自己的文章
    不能在本论坛发表投票
    不能在这个论坛添加附件
    可以在这个论坛下载文件

    论坛转跳: 

    webdriver, webdriver, callmelxylt, 飞舞的音符, webdriver, 小闪, callmelxylt, webdriver, 飞舞的音符, callmelxylt
    潜力帖子 精华帖子 热门帖子
    一周麻辣点评:地产税收就是抢钱
    哈哈马
    温东小兵,你大爷,心凉了!他不上当!
    肚子饿了觉得心慌
    这就是阿里巴巴新“数学天才”? 被...
    周一乐一乐,中国抗日神剧
    完了,He did it again
    葡萄牙真是让人着急啊&#128547;
    在首尔景福宫见到了明娘娘
    现在国际事务,都是由G7来敲啊
    不再去美国购物了
    我的蓝莓开始熟了
    2023年中国商贸物流总额达126.1万亿元
    2024年6月11日的直播视频,看看今天...
    红魔比利时正在对战斯洛伐克
    在Victoria华裔博物馆里面的一套token
    日本五日游记
    Mule Coin 无法抗拒的魅力之一:200...
    法国阿尔卑斯山区
    明天又要上班了
    漂亮的MS66
    The Value of Money
    再去chief peak
    这些是不是真货?
    同号雷达钞
    今天包粽子 兼和粉红吵架
    热烈恭贺钱币小站新任版主四季豆同学
    北温换硬币活动取消
    加拿大唯一无国籍的硬币
    每周版主推荐,美女精选(二七二)
    你们洗一次牙的价格一般多少钱?
    最近爱上了KALE
    刺伤4美国讲师 凶手身份曝光,顺便...
    从64看中国人的奴性和残暴。
    大温2室租金将达2800
    在北美得了大病真是只能等死了
    国内最骄傲的两件事外卖和快递
    乌克兰已经花掉了美国七百多亿美元
    大家如何看待北京同仁堂汞超标5万倍...
    身在海外,痛骂国内人不反抗挺坏的
    95个小时,这是看急诊吗
    疫情4年后,海外华人去中国的观感
    在加做房东有罪吗?
    坎昆比夏威夷好玩
    中国没有恐袭

    最新新闻 热门新闻 热评新闻
    生活成本高涨 越来越多加国人做兼职
    热浪滚滚 美多个州创下高温纪录
    约旦外交部:41名约旦人在沙特朝觐期间死亡
    以色列军方批准对黎巴嫩发动进攻的作战计划
    这5件最值得关注的政治事件或将决定美国大选结果
    竞争对手将退出,荷兰首相吕特将成新任北约秘书长
    刚在古巴撑完门面 俄罗斯核潜艇又出糗
    最具爆炸性的建议:与中国断绝经济联系
    不要以为黄河长江不会倒流 有时确实会倒流
    越来越多年轻人患上"结婚羞耻症" 话题登上热搜
    "应与中国经济上脱钩" 川普第二任期对华外交现端倪?
    2024年中国富豪外流人数将再创记录
    今年以来 结婚的中国人越来越少
    想不到!软壳生物建材比传统水泥坚固19倍
    不玩了 全球最大避险基金狂抛中国股票
    跨国夫妻亲手改造家,进门就解压
    帅到爆炸!吴彦祖胡子一刮颜值归位
    全屋低调大方 刘亦菲豪宅没有俗气
    大温独立屋时代即将结束!迎加税潮
    纽约公园强奸少女嫌犯落网 民众助
    这周六晚大温夜空首个无人机表演
    加国华裔9年级女生研究获奖 因为.
    为1个车位 温哥华俩白人邻居斗1年
    降息加限制移民 加国经济将迎转折
    欧洲多国电价接近零 负电价不罕见
    大温巴士总站将拆除 刚翻新装修完
    大温这街将关半年 周围将严重延误
    贷款还款增加一倍多 加国夫妇震惊
    统计局修改通胀算法 提高食物权重
    她被全家8口"吸血"多年 26岁去世...
    眼巴巴看着 一尊家门口被算计了
    正见证一个洲际变迁 俄中帝国梦魇
    大温巴士总站将拆除 刚翻新装修完
    姜萍事件是彻头彻尾的炒作,始作俑
    被困国产电动车喊救命 理想车撞一排
    贷款还款增加一倍多 加国夫妇震惊
    盗窃转卖室友奢侈品 华裔女生被捕
    多花20万买房短租 BC业主现在崩溃
    今年国庆节这些地方都能看烟花!
    全屋低调大方 刘亦菲豪宅没有俗气
    大温独立屋时代即将结束!迎加税潮
    纽约公园强奸少女嫌犯落网 民众助
    这周六晚大温夜空首个无人机表演
    加国华裔9年级女生研究获奖 因为.
    为1个车位 温哥华俩白人邻居斗1年

    更多方式阅读论坛:

    Android: 加西网
    [下载]

    Android: 温哥华论坛
    [下载]

    PDA版本: 论坛

    加西网微信

    加西网微博


    Powered by phpBB 2.0.8
    Terms & Conditions    Privacy Policy    Political ADs    Activities Agreement    Contact Us    Sitemap    

    加西网为北美中文网传媒集团旗下网站

    页面生成: 0.0629 秒 and 7 DB Queries in 0.0025 秒