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


C# HttpRequest.Get方法代码示例

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


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

示例1: Get

 static void Get(string url)
 {
     HttpRequest request = new HttpRequest();
     request.Cookies = new CookieDictionary();
     HttpResponse response = request.Get(url);
     Console.WriteLine(response.ToString());
 }
开发者ID:maltyyev,项目名称:FAMILab,代码行数:7,代码来源:Program.cs

示例2: searchButton_Click

        private void searchButton_Click(object sender, EventArgs e)
        {
            songBox.Items.Clear();
            if (searchInput.TextLength != 0)
            {
                using (var rq = new HttpRequest())
                {
                    rq.UserAgent = HttpHelper.FirefoxUserAgent();

                    if (ultimate_guitarCheck.Checked)
                    {
                        try
                        {
                            //www.ultimate-guitar.com/search.php?search_type=title&value=

                            var urlParams = new RequestParams();

                            urlParams["search_type"] = "title";
                            urlParams["value"] = searchInput.Text;

                            string content = rq.Get("http://www.ultimate-guitar.com/search.php", urlParams).ToString();

                            string[] songNames;
                            string[] urls;

                            songNames = content.Substrings("class=\"song\">", "</a>", 0);
                            urls = content.Substrings("<a href=\"" + ultimateAdress, "\" class=\"song\">", 0);

                            for (int i = 0; i < songNames.Length; i++)
                            {
                                    songNames[i] = songNames[i].Replace("<b>", "");
                                    songNames[i] = songNames[i].Replace("</b>", "");
                                    songNames[i] = songNames[i].Insert(0, i + ". ");

                                    urls[i] = urls[i].Insert(0, ultimateAdress);

                                    songs.Add(songNames[i], urls[i]);

                                    songBox.Items.Add(songNames[i]);
                            }

                        }
                        catch
                        {
                            MessageBox.Show("Что-то пошло не так");
                        }
                    }
                }
            }

            showTabButton.Enabled = true;
        }
开发者ID:he305,项目名称:UsefulProgs,代码行数:52,代码来源:Form1.cs

示例3: MainWindow_Load

        private void MainWindow_Load(object sender, EventArgs e)
        {
            showTabButton.Enabled = false;
            using (var rq = new HttpRequest())
            {
                rq.UserAgent = HttpHelper.FirefoxUserAgent();

                try
                {
                    HttpResponse response = rq.Get("http://www.ultimate-guitar.com/");
                    ultimate_guitarCheck.Checked = true;
                }
                catch
                {
                    ultimate_guitarCheck.Checked = false;
                }
            }

            if (!ultimate_guitarCheck.Checked)
                searchButton.Enabled = false;
        }
开发者ID:he305,项目名称:UsefulProgs,代码行数:21,代码来源:Form1.cs

示例4: docs_save

        public static dynamic docs_save(string path_file, string name_doc = "Unknown", string v = "5.21")
        {
            Dictionary<string, dynamic> result;
            string error = "";

            var request = new HttpRequest();
            request.AddUrlParam("access_token", Settings1.Default.token);
            request.AddUrlParam("v", v);

            try
            {
                string content = request.Get(uri_api + "docs.getUploadServer").ToString();
                result = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(content);
                string url_upload = result["response"]["upload_url"];

                request = new HttpRequest();
                request.AddFile("file", path_file);
                content = request.Post(url_upload).ToString();
                result = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(content);

                request = new HttpRequest();
                request.AddUrlParam("file", result["file"]);
                request.AddUrlParam("title", name_doc.Replace(".jpg", ""));
                request.AddUrlParam("access_token", Settings1.Default.token);
                request.AddUrlParam("v", v);

                content = request.Get(uri_api + "docs.save").ToString();
                result = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(content);
                string result_string = "doc" + result["response"][0]["owner_id"] + "_" + result["response"][0]["id"];
                return result_string;
            }
            catch (Exception ex)
            {
                MessageBox.Show(error = ex.Message + " " + ex.InnerException);
                return null;
            }
        }
开发者ID:QAsMD,项目名称:BDZ,代码行数:37,代码来源:lib_vk.cs

示例5: StartParser

        /// <summary>
        /// Парсит страницы Тольяттинских квартир.
        /// Записывает полученные данные в xml файл.
        /// Создает папку photo, в ней создает папки с id квартир и сохраняет в них фото.
        /// </summary>
        /// <param name="idApartment"></param>
        /// <returns></returns>
        public static void StartParser()
        {
            Directory.CreateDirectory("image");
            Directory.CreateDirectory("log");

            //получаем общее кол-во квартир
            var quantityApartment = 20;//GetCountPages();

            //получаем ID квартир.
            List<string> idApartment = GetAllIdApartment(quantityApartment);

            int counterFinishApartment = 0;

            //создаем файл apartment.xml
            using (var xmlWriter = new XmlTextWriter("apartment.xml", Encoding.UTF8))
            {
                try
                {
                    #region форматирование xml документа

                    xmlWriter.Formatting = Formatting.Indented;
                    xmlWriter.IndentChar = '\t';
                    xmlWriter.Indentation = 1;
                    xmlWriter.QuoteChar = '\'';

                    #endregion

                    xmlWriter.WriteStartDocument();
                    xmlWriter.WriteStartElement("ListOfApartment");

                    foreach (var idApart in idApartment)
                    {
                        using (var request = new HttpRequest())
                        {
                            //получаем страницу
                            var sourcePage = request.Get("www.volga-info.ru/togliatti/object/kvartiryi/" + idApart).ToString();

                            //парсим и одновременно пишем в файл
                            WriteToXmlFile(xmlWriter, idApart, sourcePage);

                            //парсим и получаем массив с ссылками на фотографии
                            var imageUrl = sourcePage.Substrings("<img alt=\"\" src=\"", "\" style", 0);

                            if (imageUrl.Length > 0)
                            {
                                //парсим, создаем каталоги и сохраняем в них фото
                                CreateDirAndPfoto(idApart, sourcePage, imageUrl);
                            }

                            counterFinishApartment++;
                        }
                    }

                    xmlWriter.WriteEndElement();
                }
                catch (Exception ex)
                {
                    Logger logger = LogManager.GetCurrentClassLogger();
                    logger.Error(ex);
                }
                finally
                {
                    Logger logger = LogManager.GetCurrentClassLogger();
                    logger.Info("квартир спарсено:" + counterFinishApartment);
                }
            }
        }
开发者ID:VladislavZhukov,项目名称:ParserVI,代码行数:74,代码来源:ParserVI.cs

示例6: GetCountPages

        /// <summary>
        /// Возвращает общее кол-во квартир.
        /// </summary>
        /// <returns></returns>
        private static int GetCountPages()
        {
            int countPages = 0;

            try
            {
                using (var request = new HttpRequest())
                {
                    string sourcePage;

                    //получаем страницу
                    sourcePage = request.Get("http://www.volga-info.ru/togliatti/search/kvartiryi/x").ToString();

                    foreach (var item in forParsQuantityPage)
                    {
                        var numOfPages = sourcePage.Substrings("Всего найдено ", item, 0);

                        if (numOfPages.Length != 0)
                        {
                            //парсим и получаем общее кол-во страниц
                            countPages = Convert.ToInt32(numOfPages[0]);
                        }
                    }

                }
            }
            catch (Exception ex)
            {
                Logger logger = LogManager.GetCurrentClassLogger();
                logger.Error(ex);
            }

            while (countPages % 20 != 0)
            {
                countPages--;
            }

            return countPages;
        }
开发者ID:VladislavZhukov,项目名称:ParserVI,代码行数:43,代码来源:ParserVI.cs

示例7: showTab

        private void showTab(string url)
        {
            using (var rq = new HttpRequest())
            {
                rq.UserAgent = HttpHelper.FirefoxUserAgent();

                try
                {
                    string content = rq.Get(url).ToString();

                    string tabs = content.Substrings("<pre>", "</pre>", 0)[1];
                    tabs = tabs.Replace("<i>", "");
                    tabs = tabs.Replace("</i>", "");
                    tabs = tabs.Replace("<span>", "");
                    tabs = tabs.Replace("</span>", "");

                    Tabs tabForm = new Tabs(tabs);
                    tabForm.ShowDialog();
                }

                catch
                {
                    MessageBox.Show("Что-то пошло не так");
                }
            }
        }
开发者ID:he305,项目名称:UsefulProgs,代码行数:26,代码来源:Form1.cs

示例8: friends_get

        public static dynamic friends_get(string id_user, string fields = "screen_name, photo_max_orig")
        {
            Dictionary<string, dynamic> result;
            string error;

            var request = new HttpRequest();
            request.AddUrlParam("user_ids", id_user);
            request.AddUrlParam("order", "hints");
            request.AddUrlParam("fields", fields);
            request.AddUrlParam("access_token", Settings1.Default.token);
            try
            {
                string content = request.Get(uri_api + "friends.get").ToString();
                result = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(content);

                return result["response"];
            }
            catch (Exception ex)
            {
                MessageBox.Show(error = ex.Message + " " + ex.InnerException);
                return null;
            }
        }
开发者ID:QAsMD,项目名称:BDZ,代码行数:23,代码来源:lib_vk.cs

示例9: getUploadServer

 private static dynamic getUploadServer(string group_id = "", string v = "5.21")
 {
     Dictionary<string, dynamic> result;
     string error = "";
     var request = new HttpRequest();
     request.AddUrlParam("group_id", group_id);
     request.AddUrlParam("v", v);
     request.AddUrlParam("access_token", Settings1.Default.token);
     try
     {
         string content = request.Get(uri_api + "docs.getUploadServer").ToString();
         result = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(content);
         return result["response"]["upload_url"];
     }
     catch (Exception ex)
     {
         MessageBox.Show(error = ex.Message + " " + ex.InnerException);
         return null;
     }
 }
开发者ID:QAsMD,项目名称:BDZ,代码行数:20,代码来源:lib_vk.cs

示例10: message_send

 public static dynamic message_send(string user_id, string message = "Привет от Шарпов", string attachment = "doc21881340_285976245")
 {
     Dictionary<string, dynamic> result;
     string error = "";
     var request = new HttpRequest();
     request.AddUrlParam("user_id", user_id);
     request.AddUrlParam("message", message);
     request.AddUrlParam("attachment", attachment);
     request.AddUrlParam("access_token", Settings1.Default.token);
     try
     {
         string content = request.Get(uri_api + "messages.send").ToString();
         result = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(content);
         return result["response"];
     }
     catch (Exception ex)
     {
         MessageBox.Show(error = ex.Message + " " + ex.InnerException);
         return null;
     }
 }
开发者ID:QAsMD,项目名称:BDZ,代码行数:21,代码来源:lib_vk.cs

示例11: messages_history

        public static dynamic messages_history(string id_user, string v="5.21")
        {
            Dictionary<string, dynamic> result;
            string error = "";

            var request = new HttpRequest();
            request.AddUrlParam("user_id", id_user);
            request.AddUrlParam("access_token", Settings1.Default.token);
            request.AddUrlParam("v", v);

            try
            {
                string content = request.Get(uri_api + "messages.getHistory").ToString();
                result = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(content);
                return result["response"];
            }
            catch (Exception ex)
            {
                MessageBox.Show(error = ex.Message + " " + ex.InnerException);
                return null;
            }
        }
开发者ID:QAsMD,项目名称:BDZ,代码行数:22,代码来源:lib_vk.cs

示例12: messages_get

        public static dynamic messages_get(string count = "20")
        {
            Dictionary<string, dynamic> result;
            string error = "";
            var request = new HttpRequest();
            request.AddUrlParam("out", "0");
            request.AddUrlParam("access_token", Settings1.Default.token);
            request.AddUrlParam("count", count);
            request.AddUrlParam("time_offset", "0");

            try
            {
                string content = request.Get(uri_api + "messages.get").ToString();
                result = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(content);
                return result["response"];
            }
            catch (Exception ex)
            {
                MessageBox.Show(error = ex.Message + " " + ex.InnerException);
                return null;
            }
        }
开发者ID:QAsMD,项目名称:BDZ,代码行数:22,代码来源:lib_vk.cs

示例13: getRequest

        private string getRequest(string url, string refer)
        {
            try
            {

                using (var request = new HttpRequest())
                {
                    string content;
                    request.UserAgent = HttpHelper.ChromeUserAgent();
                    request.Referer = refer;
                    request.AllowAutoRedirect = true;
                    request.Cookies = cookies;

                    HttpResponse response = request.Get(url);

                    var status = response.StatusCode.ToString();
                    using (var responseStream = response.ToStream())
                    {
                        cookies = response.Cookies;
                    }

                    content = response.ToString();

                    return content;

                }
            }
            catch (WebException we)
            {
                var wRespStatusCode = ((HttpWebResponse)we.Response).StatusCode;
                return wRespStatusCode.ToString();
            }
        }
开发者ID:ganggbang,项目名称:EndClothing,代码行数:33,代码来源:Form1.cs

示例14: StartParser

        public static void StartParser()
        {
            #region Настройки консоли
            Console.SetWindowSize(120, 10);
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.Title = "Parser VI active";
            Console.WriteLine("Парсер запущен, ожидайте окончания выполнения работы...");
            #endregion

            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(DataApartment));

                DataApartment dataApart = new DataApartment();

                string pathDataApartmentXML = "DataApartment.xml";

                if (File.Exists(pathDataApartmentXML))
                {
                    FileStream stream = new FileStream(pathDataApartmentXML, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

                    dataApart = serializer.Deserialize(stream) as DataApartment;

                    stream.Close();
                }

                var reqParams = new RequestParams();

                Directory.CreateDirectory("apartment");

                for (int i = 0; i < dataApart.UrlTypeapArtement.Count; i++)
                {
                    string typeApartament = dataApart.UrlTypeapArtement[i].Substring("/search/", "/", 0).ToString();
                    string pathCurrentApartment = "apartment/" + typeApartament;
                    string pathCurrentApartmentPhoto = pathCurrentApartment + "/photo";

                    Console.WriteLine("идет получение " + typeApartament);

                    Directory.CreateDirectory(pathCurrentApartment);
                    Directory.CreateDirectory(pathCurrentApartmentPhoto);

                    using (var xmlWriter = new XmlTextWriter(pathCurrentApartment + "/info_" + typeApartament + ".xml", Encoding.UTF8))
                    {
                        //получаем общее кол-во квартир
                        var quantityApartment = 20;//GetCountPages();

                        //получаем ID квартир.
                        List<string> idApartment = GetAllIdApartment(quantityApartment, dataApart.UrlTypeapArtement[i]);

                        //счетчик записанных в файл жилищь
                        int counterFinishApartment = 0;

                        #region форматирование xml документа

                        xmlWriter.Formatting = Formatting.Indented;
                        xmlWriter.IndentChar = '\t';
                        xmlWriter.Indentation = 1;
                        xmlWriter.QuoteChar = '\'';

                        #endregion

                        xmlWriter.WriteStartDocument();
                        xmlWriter.WriteStartElement("ListOfApartment");

                        foreach (var idApart in idApartment)
                        {
                            using (var request = new HttpRequest())
                            {
                                Console.WriteLine("Готовые " + typeApartament + " = " + counterFinishApartment);

                                string urlApartment = dataApart.UrlTypeapArtement[i].Replace("/x", "/").Replace("search", "object") + idApart;

                                DateTime startTime = DateTime.Now;
                                Console.WriteLine("Получение данных со страницы: " + urlApartment);

                                //получаем страницу
                                string sourcePage = null;

                                try
                                {
                                    sourcePage = request.Get(urlApartment).ToString();
                                }
                                catch (Exception ex)
                                {
                                    Logger logger = LogManager.GetCurrentClassLogger();
                                    logger.Info("не удалось загрузить квартиру" + " " + urlApartment);
                                    continue;
                                }

                                Console.WriteLine("Данные полученны за: " + (DateTime.Now - startTime).TotalMilliseconds + "\nНачат процесс парсинга данных и загрузки их на диск...");

                                switch (typeApartament)
                                {
                                    case "kvartiryi":
                                        //парсим и одновременно пишем в файл
                                        WriteToXmlFile(dataApart.ParsKvartiryiList, dataApart.XmlKvartiryiList, xmlWriter, idApart, sourcePage);
                                        break;
                                    case "dolevoe":
                                        WriteToXmlFile(dataApart.ParsDolevoeList, dataApart.XmlDolevoeList, xmlWriter, idApart, sourcePage);
                                        break;
//.........这里部分代码省略.........
开发者ID:VladislavZhukov,项目名称:ParserVI,代码行数:101,代码来源:ParserVI_All.cs


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