Files
telegram-bot/modules/Destiny2.WhereIsXur/Provider/XurWiki.cs
T

27 lines
644 B
C#
Raw Normal View History

2020-03-09 20:12:03 +04:00
using System.Threading.Tasks;
using Fizzler.Systems.HtmlAgilityPack;
using HtmlAgilityPack;
2023-07-29 15:14:52 +03:00
namespace Kruzya.TelegramBot.Destiny2.WhereIsXur.Provider;
public class XurWiki : IXurPlaceProvider
2020-03-09 20:12:03 +04:00
{
2023-07-29 15:14:52 +03:00
public async Task<string> GetPlaceAsync()
2020-03-09 20:12:03 +04:00
{
2023-07-29 15:14:52 +03:00
var web = new HtmlWeb();
var document = await web.LoadFromWebAsync("https://xur.wiki");
2020-03-09 20:12:03 +04:00
2023-07-29 15:14:52 +03:00
var place = document.DocumentNode.QuerySelector(".location_name");
if (place != null)
2020-03-09 20:12:03 +04:00
{
2023-07-29 15:14:52 +03:00
return place.InnerText.Trim();
2020-03-09 20:12:03 +04:00
}
2023-07-29 15:14:52 +03:00
return "";
}
public string GetPlace()
{
return GetPlaceAsync().GetAwaiter().GetResult();
2020-03-09 20:12:03 +04:00
}
}