Title and description extraction now only look in the head section of the HTML document

This commit is contained in:
2024-12-23 14:09:51 +01:00
parent 580d687f62
commit e9fd738f1f
8 changed files with 63 additions and 38 deletions
+8 -12
View File
@@ -161,15 +161,15 @@ public class ContentFilter
for (int i = 0; i < ports.Length; i++)
{
string? html = "";
if (ports[i] == 80)
{
if (string.IsNullOrWhiteSpace(url1)) continue;
try
{
html = HttpClientHelper.GetHtml(url1, 80).GetAwaiter().GetResult();
(string, string) temp = HttpClientHelper.GetTitleAndDescription(url1, 80).GetAwaiter().GetResult();
title1 = temp.Item1;
description1 = temp.Item2;
}
catch
{
@@ -179,10 +179,12 @@ public class ContentFilter
else
{
if (string.IsNullOrWhiteSpace(url2)) continue;
try
{
html = HttpClientHelper.GetHtml(url2, 443).GetAwaiter().GetResult();
(string, string) temp = HttpClientHelper.GetTitleAndDescription(url1, 443).GetAwaiter().GetResult();
title2 = temp.Item1;
description2 = temp.Item2;
}
catch
{
@@ -190,12 +192,6 @@ public class ContentFilter
}
}
if (string.IsNullOrWhiteSpace(html)) continue;
if (ports[i] == 80 && string.IsNullOrWhiteSpace(title1)) { FilterHelper.GetTitle(html, out title1); }
if (ports[i] == 443 && string.IsNullOrWhiteSpace(title2)) { FilterHelper.GetTitle(html ,out title2); }
if (ports[i] == 80 && string.IsNullOrWhiteSpace(description1)) { FilterHelper.GetDescription(html, out description1); }
if (ports[i] == 443 && string.IsNullOrWhiteSpace(description2)) { FilterHelper.GetDescription(html, out description2); }
if (ports[i] == 80 && !robotsTxt1) { robotsTxt1 = HttpClientHelper.HasRobotsTxt(url1, 80).GetAwaiter().GetResult(); }
if (ports[i] == 443 && !robotsTxt2) { robotsTxt2 = HttpClientHelper.HasRobotsTxt(url2, 443).GetAwaiter().GetResult(); }
}
+1 -1
View File
@@ -59,7 +59,7 @@ public class ThreadHandler
{
Thread.Sleep(5000); // Let the database handler instantiate and warm up first.
List<WaitHandle[]> wait = _ipScanner.Start(32);
List<WaitHandle[]> wait = _ipScanner.Start(128);
for (int i = 0; i < wait.Count; i++)
{