📄 shili.txt
字号:
public class Top18List
{
private static Top18List instance = null;
private static string P8Url = ConfigurationManager.AppSettings["p8url"];
private string[] urls;
private string[] names;
private DateTime updatetime;
public string[] this[int index]{
get
{
return new string[] {urls[index],names[index]};
}
}
private Top18List()
{
getUrlsAndNames();
}
private void getUrlsAndNames()
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(P8Url
);
HttpWebResponse response = (HttpWebResponse)request.GetResponse(
);
Stream s = response.GetResponseStream();
string x = "";
if (response.ContentEncoding == "gzip")
{
x = new StreamReader(new GZipStream(s, CompressionMode.Decom
press), Encoding.GetEncoding("gbk")).ReadToEnd();
}
else
{
x = new StreamReader(s, Encoding.GetEncoding("gbk")).ReadToE
nd();
}
Regex reg = new Regex(@"<a href=""(?<link>[^""]+)"" [^>]+>·(?<n
ame>[^<]+)</a>");
Match m = reg.Match(x);
List<string> listUrls = new List<string>();
List<string> listNames = new List<string>();
while (m.Success)
{
listUrls.Add(m.Groups["link"].Value);
listNames.Add(m.Groups["name"].Value);
m = m.NextMatch();
}
urls = listUrls.ToArray();
names = listNames.ToArray();
s.Close();
response.Close();
}
catch (Exception e)
{
Trace.Write(DateTime.Now);
Trace.WriteLine(e.Source);
Trace.WriteLine(e.Message);
Trace.WriteLine(e.StackTrace);
}
updatetime = DateTime.Now;
}
public static Top18List getInstance()
{
if (instance == null)
{
instance = new Top18List();
}
else
{
if (instance.updatetime.AddMinutes(60) < DateTime.Now)
{
instance.getUrlsAndNames();
}
}
return instance;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -