DouYa.Collect/CollectHtml.cs

(开头部分) 14KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;
using System.Linq;

namespace DouYa.Collect
{
    // 下载于www.51aspx.com
    public class CollectHtml
    {
        /// <summary>
        /// Get HTML
        /// </summary>
        /// <param name="Url"></param>
        /// <param name="charset"></param>
        /// <returns></returns>
        public static string GetHtmlSource(string Url, string charset)
        {
            if (charset == "" || charset == null) charset = "gb2312";
            string htmltext = "";
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
                //Stream stream = (Stream)request.BeginGetResponse(new AsyncCallback(ProcessResponse), request);
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream stream = response.GetResponseStream();
                StreamReader reader = new StreamReader(stream, Encoding.GetEncoding(charset));
                htmltext = reader.ReadToEnd();
                stream.Close();
                response.Close();
                request.Abort();
            }
            catch (Exception exception)
            {
            }
            return htmltext;
        }
  
        //public string GetRemoteHtmlCode(string Url) 
        //{ 
        //    string s = ""; 
        //    MSXML2.XMLHTTP _xmlhttp = new MSXML2.XMLHTTPClass(); 
        //    _xmlhttp.open("GET", Url, false, null, null); 
        //    _xmlhttp.send(""); 
        //   if (_xmlhttp.readyState == 4) 
        //    { 
        //        s = System.Text.Encoding.Default.GetString((byte[])_xmlhttp.responseBody);
        //    } 
        //    return s; 
        //} 


        /// <summary>
        /// 替换网页中的换行
        /// </summary>
        /// <param name="HtmlCode">HTML源代码</param>
        /// <returns></returns>
后面还有 316 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。