Skip to content

Instantly share code, notes, and snippets.

@nzhul
Created May 20, 2016 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nzhul/178b8e5402aa451c3147d0f15ed17827 to your computer and use it in GitHub Desktop.
Save nzhul/178b8e5402aa451c3147d0f15ed17827 to your computer and use it in GitHub Desktop.
using System;
using System.Net;
using System.Text;
using System.Threading;
namespace WebPageWatcher
{
public class Program
{
public static State state;
static void Main(string[] args)
{
while (true)
{
Thread.Sleep(60 * 60 * 1000);
DoCheck();
}
}
private static void DoCheck()
{
WebClient myClient = new WebClient();
myClient.Encoding = System.Text.Encoding.UTF8;
string sourceCode = myClient.DownloadString("http://www.kinoarena.com/bg/brand/IMAX/filmi/kino-arena-mladost");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < sourceCode.Length; i++)
{
char currentCharacter = sourceCode[i];
if (currentCharacter == '<' && state != State.InHeading)
{
if (sourceCode[i + 1] == 'h' && sourceCode[i + 2] == '5')
{
state = State.InHeading;
}
else
{
state = State.Normal;
}
}
if (currentCharacter == '>' && state == State.InHeading)
{
if (sourceCode[i - 1] == '5')
{
state = State.Normal;
sb.Append('>');
sb.Append('|');
}
}
if (state == State.InHeading)
{
sb.Append(currentCharacter);
}
}
string result = sb.ToString().ToLower();
string[] keywords = { "warcraft", "warcraft", "уоркрафт", "уаркрафт", "уъркрафт" };
for (int i = 0; i < keywords.Length; i++)
{
if (result.IndexOf(keywords[i]) > -1)
{
Console.WriteLine("YES BABY!");
// TODO: MailTo dobromirivanov1@gmail.com
}
}
}
}
public enum State
{
Normal,
InHeading
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment