CommunalHelper.cs 1008 B

12345678910111213141516171819202122232425262728293031323334
  1. using System.IO;
  2. namespace CB.Admin.Plugins
  3. {
  4. public static class CommunalHelper
  5. {
  6. private static HttpHelper _Helper = new HttpHelper();
  7. /// <summary>
  8. /// Http请求
  9. /// </summary>
  10. /// <param name="url"></param>
  11. /// <param name="type"></param>
  12. /// <returns></returns>
  13. public static string HttpRequest(string url, string type = "text/html")
  14. {
  15. HttpItem _item = new HttpItem
  16. {
  17. Url = url,
  18. Method = "get",
  19. Accept = "text/html",
  20. ContentType = type,
  21. Timeout = 90,
  22. UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
  23. };
  24. //
  25. HttpResult result = _Helper.GetHtml(_item);
  26. if ((int)result.StatusCode == 200 && !string.IsNullOrEmpty(result.Html))
  27. return result.Html;
  28. else
  29. return "";
  30. }
  31. }
  32. }