The "*" are my credentials to log in, and are set to variables. When I run the code, my returned value is a string stating my conditional statement, else value. I am pretty sure I am thinking in the right direction, but somewhere in my thought process its getting mixed up. I hope its a simple fix. Also bare with me I am a firefighter not a coder lol
using HtmlAgilityPack;
using System;
using System.Net;
class Program
{
static void Main(string[] args)
{
string url = "https://app.bryx911.com/login";
string[] keywords = { "M02", "E56", "L25" };
string username = "**********";
string password = "*******";
using (var handler = new HttpClientHandler { CookieContainer = new CookieContainer(), UseCookies = true })
{
using (HttpClient client = new HttpClient(handler))
{
var loginContent = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("Email...", username),
new KeyValuePair<string, string>("Password...", password)
});
var loginResult = client.PostAsync("https://app.bryx911.com/login", loginContent).Result;
if (loginResult.IsSuccessStatusCode)
{
var responseContent = client.GetAsync(url).Result.Content.ReadAsStringAsync().Result;
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(responseContent);
foreach (string keyword in keywords)
{
if (doc.DocumentNode.InnerText.Contains(keyword))
{
Console.WriteLine($"Found '{keyword}' on the page.");
}
else
{
Console.WriteLine($"Could not find '{keyword}' on the page.");
}
}
}
else
{
Console.WriteLine("Login failed.");
}
}
}
}
}
Thank you in advance, much appreciated.