当前位置: 首页>>代码示例>>C#>>正文


C# System.Net.WebClient.UploadStringAsync方法代码示例

本文整理汇总了C#中System.Net.WebClient.UploadStringAsync方法的典型用法代码示例。如果您正苦于以下问题:C# System.Net.WebClient.UploadStringAsync方法的具体用法?C# System.Net.WebClient.UploadStringAsync怎么用?C# System.Net.WebClient.UploadStringAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.WebClient的用法示例。


在下文中一共展示了System.Net.WebClient.UploadStringAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StartList

        /// <summary>
        /// 1.开始列表获取
        /// </summary>
        /// <param name="path"></param>
        /// <param name="iType"></param>
        public static void StartList(string path, LiuXingType iType)
        {
            if (string.IsNullOrEmpty(path)) return;
            // 解析数据
            using
            (
                var datadown = new System.Net.WebClient
                {
                    Encoding = iType.Encoding,
                    Proxy = iType.Proxy
                }
            )
            {
                datadown.Headers.Add(System.Net.HttpRequestHeader.UserAgent, "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1581.2 Safari/537.36");
                if (iType.Sign.Contains("M1905List"))
                {
                    datadown.Headers.Add("order", "listorder");
                    datadown.Headers.Add("videotype", "3");
                    datadown.Headers.Add(System.Net.HttpRequestHeader.ContentType, "application/x-www-form-urlencoded");
                    datadown.UploadStringAsync(new System.Uri(path), "POST", "page=1&pagesize=10&order=listorder&videotype=3", iType);
                    datadown.UploadStringCompleted += Datadown_UploadStringCompleted;
                }
                else
                {
                    if (iType.Sign.Contains("M1905Second"))
                    {
                        datadown.Headers.Add("filmid", iType.Sign.Split(',')[1]);
                        datadown.Headers.Add(System.Net.HttpRequestHeader.ContentType, "application/x-www-form-urlencoded");
                        datadown.UploadStringAsync(new System.Uri(UrlCodeHelper.GetListHttpPath(0, 0, iType).Replace("filmlist", "filmdetail")), "POST", "filmid=" + iType.Sign.Split(',')[1], iType);
                        datadown.UploadStringCompleted += Datadown_UploadStringCompleted;
                    }
                    else
                    {
                        if (iType.Type == LiuXingEnum.ZhangYuSearchItem)
                        {
                            datadown.Headers.Add("Cookie", "Hm_lvt_69521636d966ad606a32d89b1d70ee73=1376875963,1376889226; Hm_lpvt_69521636d966ad606a32d89b1d70ee73=1376889233; ce=gY1lvwT");
                        }
                        if (iType.Type == LiuXingEnum.DyfmHotApi)
                        {
                            datadown.Headers.Add("Cookie", "last_visit=" + System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 24) + "Hm_lpvt_10701d9b4e040e37e58bee7e1ec1d252=1376902145");
                        }
                        datadown.DownloadStringAsync(new System.Uri(path), iType);
                        datadown.DownloadStringCompleted += Datadown_DownloadStringCompleted;
                    }
                }

            }
        }
开发者ID:RyanFu,项目名称:A51C1B616A294D4BBD6D3D46FD7F78A7,代码行数:53,代码来源:ListStart.cs


注:本文中的System.Net.WebClient.UploadStringAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。