<commit_before>﻿using AngleSharp;
using AngleSharp.DOM;
using AngleSharp.DOM.Css;
using AngleSharp.DOM.Html;
using AngleSharp.Parser.Css;
using AngleSharp.Parser.Html;
using ConsoleInteraction.Assets;
using System;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Net.Http;
using System.Resources;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleInteraction
{
    class Program
    {
        static void Main(string[] args)
        {
            //var form = new ConsoleForm(DocumentBuilder.Html(new Uri("http://localhost:48609/PostNormal"), new Configuration { AllowRequests = true }));
            //var form = new ConsoleForm("<form method=post action='http://requestb.in/1hc34c81'><input type=hidden name=q value=r><input type=text name=Name><input type=text name=Birthday><input type=text name=Remark></form>");
            //var form = new ConsoleForm("<form method=post action='http://requestb.in/1hc34c81' enctype='multipart/form-data'><input type=hidden name=q value=r><input type=text name=Name><input type=text name=Birthday><input type=text name=Remark><input type=file name=myfile></form>");
            //var form = new ConsoleForm("<form method=post action='http://requestb.in/1hc34c81' enctype='text/plain'><input type=hidden name=q value=r><input type=text name=Name><input type=text name=Birthday><input type=text name=Remark></form>");
            //form.FillInteractive();
            //form.Submit();

            TestAsync().Wait();
  
            CssSelectorTest.Slickspeed();

            //TestCSSFrom("http://www.facebook.com");

            //TestCSSFrom("http://www.tumblr.com");

            //TestCSSFrom("http://www.flickr.com");

            TestCSS(Stylesheets.rsi, "a sample stylesheet");

            TestCSS(Stylesheets.CodeProject, "CodeProject's stylesheet");

            TestHtml(Snippets.Invalid, "an invalid snippet");

            ReadHtmlFiles(HtmlFiles.ResourceManager);

            TestHtmlFrom("http://www.imdb.com/", false);

            TestHtmlFrom("http://www.dailymail.co.uk/‎", false);

            TestHtmlFrom("http://news.google.com/", false);

            TestHtmlFrom("http://www.huffingtonpost.com/", false);

            TestHtmlFrom("http://www.nbcnews.com/", false);

            TestHtmlFrom("http://www.amazon.com/", false);

            TestHtmlFrom("http://www.yahoo.com/", false);

            TestHtmlFrom("http://www.codeproject.com/", false);

            TestHtmlFrom("http://www.florian-rappl.de/", false);
        }

        public static async Task test()
        {

            var httpClient = new HttpClient();
            var response = await httpClient.GetStreamAsync(new Uri("http://trade.500.com/bjdc/?expect=140107"));
            var document = DocumentBuilder.Html(response);

            var ls = document.GetElementsByClassName("vs_lines");
            var ls2 = document.GetElementsByClassName("vs_lines even");
            var c = ls.Concat(ls2);

            foreach (var item in c)
            {
                var tr = item as IHtmlTableRowElement;

                if (tr.Index % 2 == 0)
                    tr.Style.Display = "none";
            }
        }

        static async Task TestAsync()
        {
            Console.WriteLine("Starting async!");
            var sw = Stopwatch.StartNew();
            var parser = new HtmlParser(HtmlFiles.W3C);

            var task = parser.ParseAsync();

            while (!task.IsCompleted)
            {
                await Task.Delay(15);
                Console.WriteLine("{0} | {1} elements", sw.ElapsedMilliseconds, parser.Result.All.Length);
            }

            sw.Stop();
            Console.WriteLine("Done!");
        }

        static void ReadHtmlFiles(ResourceManager resourceManager)
        {
            var rs = resourceManager.GetResourceSet(CultureInfo.CurrentCulture, true, true);
            var it = rs.GetEnumerator();

            while (it.MoveNext())
                TestHtml(it.Value.ToString(), it.Key.ToString());<commit_msg>More playing around<commit_after>﻿using AngleSharp;
using AngleSharp.DOM;
using AngleSharp.DOM.Css;
using AngleSharp.DOM.Html;
using AngleSharp.Parser.Css;
using AngleSharp.Parser.Html;
using ConsoleInteraction.Assets;
using System;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Net.Http;
using System.Resources;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleInteraction
{
    class Program
    {
        static void Main(string[] args)
        {
            //var form = new ConsoleForm(DocumentBuilder.Html(new Uri("http://localhost:48609/PostNormal"), new Configuration { AllowRequests = true }));
            //var form = new ConsoleForm("<form method=post action='http://requestb.in/1hc34c81'><input type=hidden name=q value=r><input type=text name=Name><input type=text name=Birthday><input type=text name=Remark></form>");
            //var form = new ConsoleForm("<form method=post action='http://requestb.in/1hc34c81' enctype='multipart/form-data'><input type=hidden name=q value=r><input type=text name=Name><input type=text name=Birthday><input type=text name=Remark><input type=file name=myfile></form>");
            //var form = new ConsoleForm("<form method=post action='http://requestb.in/1hc34c81' enctype='text/plain'><input type=hidden name=q value=r><input type=text name=Name><input type=text name=Birthday><input type=text name=Remark></form>");
            //form.FillInteractive();
            //form.Submit();

            TestAsync().Wait();
  
            CssSelectorTest.Slickspeed();

            TestCSSFrom("http://www.facebook.com");

            TestCSSFrom("http://www.tumblr.com");

            TestCSSFrom("http://www.flickr.com");

            TestCSS(Stylesheets.rsi, "a sample stylesheet");

            TestCSS(Stylesheets.CodeProject, "CodeProject's stylesheet");

            TestHtml(Snippets.Invalid, "an invalid snippet");

            ReadHtmlFiles(HtmlFiles.ResourceManager);

            TestHtmlFrom("http://www.imdb.com/", false);

            TestHtmlFrom("http://www.dailymail.co.uk/‎", false);

            TestHtmlFrom("http://news.google.com/", false);

            TestHtmlFrom("http://www.huffingtonpost.com/", false);

            TestHtmlFrom("http://www.nbcnews.com/", false);

            TestHtmlFrom("http://www.amazon.com/", false);

            TestHtmlFrom("http://www.yahoo.com/", false);

            TestHtmlFrom("http://www.codeproject.com/", false);

            TestHtmlFrom("http://www.florian-rappl.de/", false);
        }

        public static async Task test()
        {

            var httpClient = new HttpClient();
            var response = await httpClient.GetStreamAsync(new Uri("http://trade.500.com/bjdc/?expect=140107"));
            var document = DocumentBuilder.Html(response);

            var ls = document.GetElementsByClassName("vs_lines");
            var ls2 = document.GetElementsByClassName("vs_lines even");
            var c = ls.Concat(ls2);

            foreach (var item in c)
            {
                var tr = item as IHtmlTableRowElement;

                if (tr.Index % 2 == 0)
                    tr.Style.Display = "none";
            }
        }

        static async Task TestAsync()
        {
            Console.WriteLine("Starting async!");
            var parser = new HtmlParser(HtmlFiles.W3C);

            var task = parser.ParseAsync();
            var sw = Stopwatch.StartNew();

            while (!task.IsCompleted)
            {
                await Task.Delay(15);
                Console.WriteLine("{0} | {1} elements", sw.ElapsedMilliseconds, parser.Result.All.Length);
            }

            sw.Stop();
            Console.WriteLine("Done!");
        }

        static void ReadHtmlFiles(ResourceManager resourceManager)
        {
            var rs = resourceManager.GetResourceSet(CultureInfo.CurrentCulture, true, true);
            var it = rs.GetEnumerator();

            while (it.MoveNext())
                TestHtml(it.Value.ToString(), it.Key.ToString());
{'fraction_non_alphanumeric': 0.13663220088626293, 'fraction_numerical': 0.009354997538158542, 'mean_word_length': 2.438425730004232, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 22, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5498471', 'n_tokens_mistral': 2390, 'n_tokens_neox': 2261, 'n_words': 439}