Song.Extend/Html/Context.cs
(开头部分) 7KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace Song.Extend.Html
{
public class Context
{
private string _text;
/// <summary>
/// 完整的HTML数据
/// </summary>
public string Text
{
get { return _text; }
set { _text = value; }
}
private string _title;
/// <summary>
/// HTML页面的标题
/// </summary>
public string Title
{
get
{
Regex re = new Regex(@"(?<=<[\s]*title[^>]*>)(.*?)(?=</[\s]*title[^>]*>)", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
MatchCollection mc = re.Matches(this._text);
foreach (Match ma in mc)
{
this._title = ma.Value;
}
return _title;
}
set
{
this._title = value;
this._text = Regex.Replace(this._text, @"(?<=<[\s]*title[^>]*>)(.*?)(?=</[\s]*title[^>]*>)", value);
}
}
private string _body;
public string Body
{
get
{
Regex re = new Regex(@"(?<=<[\s]*body[^>]*>)(.*?)(?=</[\s]*body[^>]*>)", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
MatchCollection mc = re.Matches(this._text);
foreach (Match ma in mc)
{
this._body = ma.Value;
}
return _body;
}
}
/// <summary>
/// 获取某个标签里内的文本
/// </summary>
/// <param name="label"></param>
/// <returns></returns>
后面还有 134 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
