Where is Xur?

This commit is contained in:
2020-03-09 20:12:03 +04:00
parent 768a0d064f
commit c42992f579
6 changed files with 117 additions and 0 deletions
@@ -0,0 +1,10 @@
using System.Threading.Tasks;
namespace Kruzya.TelegramBot.Destiny2.WhereIsXur.Provider
{
public interface IXurPlaceProvider
{
public Task<string> GetPlaceAsync();
public string GetPlace();
}
}
@@ -0,0 +1,28 @@
using System.Threading.Tasks;
using Fizzler.Systems.HtmlAgilityPack;
using HtmlAgilityPack;
namespace Kruzya.TelegramBot.Destiny2.WhereIsXur.Provider
{
public class XurWiki : IXurPlaceProvider
{
public async Task<string> GetPlaceAsync()
{
var web = new HtmlWeb();
var document = await web.LoadFromWebAsync("https://xur.wiki");
var place = document.DocumentNode.QuerySelector(".location_name");
if (place != null)
{
return place.InnerText.Trim();
}
return "";
}
public string GetPlace()
{
return GetPlaceAsync().GetAwaiter().GetResult();
}
}
}