<div class="title-info">
<div>
在线关键词密度计算
</div>
</div>
<form method="get">
<div class="inpuire">
<input type="text" style="width: 200px;" name="wd" placeholder="请输入关键词" value="<%=wd %>" />
<input type="text" style="width: 500px;" name="site" placeholder="请输入网站网址" value="<%=site %>" />
<button>计算</button>
</div>
</form>
<%--文本域部分--%>
<div class="textarea-cont ip-inpuire">
<p style="font-weight: bold;">以下是网站关键字的密度检测结果</p>
<div>
<p>您检查的为网址:<span style="color: red;"><%=site %></span></p>
<p>您检查的关键词:<span style="color: red;"><%=wd %></span></p>
<p>页面文本总长度:<span style="color: red;"><%=htmlcount %>个字符</span></p>
<p>关键字符串长度:<span style="color: red;"><%=wd.Length %>个字符</span></p>
<p>关键字出现次数:<span style="color: red;"><%=wdcount %>次</span></p>
<p>关键字符总长度:<span style="color: red;"><%=wd.Length*wdcount %>个字符</span></p>
<p>密度结果计算是:<span style="color: red;"><%=wdmidu %></span></p>
<p>锐拓SEO密度建议值:<span style="color: red;">2%≦密度≦8%</span></p>
</div>
<p style="padding-top: 36px;" class="explain"><span>注解:通过本工具可以快速检测页面关键词出现的数量和密度,更适合蜘蛛的搜索。</span></p>
</div>
<div class="textarea-cont ip-inpuire">
<p style="font-weight: bold;">网站网址对应的纯文本html内容</p>
<div>
<p><%=html %></p>
</div>
</div>
//http
HttpHelper http = new HttpHelper();
//关键字
public string wd =string.Empty;
//网址
public string site = string.Empty, html = string.Empty;
//页面文本总长度
public int htmlcount = 0;
//关键字符串长度
public int wdlength = 0;
//关键字出现次数
public Double wdcount = 0;
//关键字符总长度
public int wdsum = 0;
//密度结果计算是
public string wdmidu = "0.00%";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
wd = InputHelper.GetInputString(Request["wd"]).Trim();
site = InputHelper.GetInputString(Request["site"]).ToLower().Trim();
if (!string.IsNullOrWhiteSpace(site))
{
Boolean isurl = site.StartsWith("http://") || site.StartsWith("https://");
if (!isurl)
{
site = $"http://{ site}";
}
//获取密度
HttpItem item = new HttpItem()
{
URL = site
};
HttpResult result = http.GetHtml(item);
html = HtmlHelper.StripHTML(result.Html);
//html总长度
htmlcount = html.Length;
if (Regex.IsMatch(html, wd))
{
//存在
wdcount = Regex.Matches(html, wd).Count;
Double midu = (wdcount * wd.Length) / htmlcount;
wdmidu = midu.ToString("0.00%");
}
}
}
catch (Exception)
{
}
}
}
clrscr 发表于 2019-10-29 15:08
大家来找茬:
功能好,体验一般;
适配不好,如果窗口不是全屏或者最大,显示不全,左侧被挤的靠边缘挨着 ...
欢迎光临 苏飞论坛 (http://www.sufeinet.com/) | Powered by Discuz! X3.4 |