Пример #1
0
        public void GetAllQuestionsFromFile()
        {
            string html  = System.IO.File.ReadAllText(@"C:\Users\miles.sasportas\Desktop\BS Html\testHtmlQuestions.htm");
            var    tbone = HtmlParsing.GetElementValue(html, "div", HtmlParsingOptions.UnsureAttributeValues, "id", "class");

            Assert.AreEqual(18, tbone.Length);
        }
Пример #2
0
        public void UnsureAttributesWithFileAsHtml()
        {
            string html = System.IO.File.ReadAllText(@"C:\Users\miles.sasportas\Desktop\TestHTML.htm");
            var    t    = HtmlParsing.GetElementValue(html, "form", HtmlParsingOptions.UnsureAttributeValues, "id", "class", "action", "method", "autocomplete");

            Assert.IsFalse(false);
        }
Пример #3
0
        static void Main(string[] args)
        {
            debug();
            return;

#if DEBUG
            args = new string[] { @"C:\Users\miles.sasportas\Dropbox\Ausbildungssachen\Moodle Klausuren\OuG 02\OuG 02 erweitert mit Netzplan\KA OuG 02 erweitert mit Netzplan.htm" };
#endif
            //check if there are arguments
            if (args.Length == 0)
            {
                System.Console.WriteLine("Bitte Pfad zum htm(l) dokument als Startparameter anfügen.");
                BS14Library.Console.PrintExitText();
                return;
            }

            //read in the file
            var file = File.ReadAllText(args[0]);

            //get the main part wehere all infos are nested
            string mainInformation = System.IO.File.ReadAllText(@"C:\Users\miles.sasportas\Desktop\TestHTML.htm");  // TODO for testingHtmlParsing.GetElementValue(file, "div", "role=\"main\"");
            //almost 2 mins for the main infor to be parsed
            //TODO irgnore for now    string info = HtmlParsing.GetElementValue(mainInformation, "table", "class=\"generaltable generalbox quizreviewsummary\"");
            //ca 1 min 10 sekunden für den hier
            var questions = HtmlParsing.GetElementValue(mainInformation, "form", HtmlParsingOptions.UnsureAttributeValues, "id", "class", "action", "method", "autocomplete");
            //this step rouhly takes 66 seconds
        }
Пример #4
0
        private static void debug()
        {
            var files = System.IO.Directory.GetFiles(@"C:\Users\miles.sasportas\Desktop\BS Html\quesions");
            var dir   = @"C:\Users\miles.sasportas\Desktop\BS Html\quesions\aufgedroselt\";

            foreach (string file in files)
            {
                string html = System.IO.File.ReadAllText(file);
                string frage, answerBlock, richtigeAntwort;
                try
                {
                    //if it's a normal quesiton
                    frage           = HtmlParsing.GetElementValue(html, "div", "class=\"qtext\"");
                    answerBlock     = HtmlParsing.GetElementValue(html, "div", "class=\"ablock\"");
                    richtigeAntwort = HtmlParsing.GetElementValue(html, "div", "class=\"rightanswer\"");
                }
                catch (Exception)
                {
                    //happens on atleast a dorpdown
                    frage = "Todo Dropdown"; answerBlock = "TODO Dropdown"; richtigeAntwort = "TODO Dropdown";
                }
                string f = System.IO.Path.GetFileNameWithoutExtension(file) + ".htm";
                File.WriteAllText(dir + f, "Fragen:\r\n\r\n" + frage + "\r\nAntworten\r\n\r\n" + answerBlock + "\r\nRichtige Antwort\r\n\r\n" + richtigeAntwort);
            }
        }
 public HtmlService(string html)
 {
     _html        = html;
     _result      = new List <string>();
     _name        = new List <string>();
     _value       = new List <string>();
     _htmlParsing = new HtmlParsing();
 }
        public ActionResult Index()
        {
            List <NazdaqData> display = HtmlParsing.getData();

            NazdaqCSV.dataToCSV(display);

            return(View(display));
        }
Пример #7
0
        public static async Task <string> GetSongLyrics(SongBundle song)
        {
            HtmlWeb      web = new HtmlWeb();
            HtmlDocument doc = await web.LoadFromWebAsync("https://genius.com" + song.Normal.Path);

            Log(Logging.Type.Processing, "Parsing HTML...");
            return(await HtmlParsing.ParseHtml(doc));
        }
Пример #8
0
        public void UnsureAttributes()
        {
            var  t = HtmlParsing.GetElementValue(html, "div", HtmlParsingOptions.UnsureAttributeValues, "class", "length", "height");
            bool b = false, c = false;

            b = (t[0].Element == "div") && (t[0].Attributes["class"] == "third") && (t[0].Attributes["length"] == "3-42") && (t[0].Attributes["height"] == "3-42");
            c = (t[1].Element == "div") && (t[1].Attributes["class"] == "fourth") && (t[1].Attributes["length"] == "4") && (t[1].Attributes["height"] == "4");
            Assert.IsTrue(b && c);
        }
Пример #9
0
        //export hasła do tymczasowego pliku Html
        private static void ExecuteExportToHtml(List <DictionaryPasswordElement> elements)
        {
            var dictionaryPasswordElements = new ObservableCollection <DictionaryPasswordElement>(elements);

            var textDocumentAdv = HtmlParsing.ParsowanieHtml(dictionaryPasswordElements);

            using (var t = File.Create(Path.GetTempPath() + @"\temp.html"))
            {
                HTMLExporting.ConvertToHtml(textDocumentAdv, t);
            }
        }
Пример #10
0
        public ActionResult Refresh()
        {
            List <NDData> toInsert = new List <NDData>();

            try
            {
                toInsert = HtmlParsing.getData();
            } catch
            {
                return(RedirectToAction("ErrorPage", "Home"));
            }
            foreach (NDData item in toInsert)
            {
                SQLHelper.Insert(item, InformationMethods.retrieveUserData());
            }

            return(RedirectToAction("Index", "Home"));
        }
Пример #11
0
        //zapis jako... zanalizowanego hasła do pliku
        private void ExecuteSaveAsCommand()
        {
            if (_recognizePasswordListObservableCollection.Count <= 0)
            {
                return;
            }

            var saveFileDialog = new SaveFileDialog
            {
                DefaultExt = ".txt",
                Filter     =
                    "JSON (*.json)|*.json|" +
                    "html (*.html)|*.html|" +
                    "Plain text (*.txt)|*.txt",

                Title = "Zapis"
            };

            var result = saveFileDialog.ShowDialog();

            if (result != true)
            {
                return;
            }
            switch (saveFileDialog.FilterIndex)
            {
            case 1:
                File.WriteAllText(saveFileDialog.FileName,
                                  JsonConvert.SerializeObject(_recognizePasswordListObservableCollection,
                                                              Formatting.Indented));
                break;

            case 2:
                HTMLExporting.ConvertToHtml(HtmlParsing.ParsowanieHtml(_recognizePasswordListObservableCollection), File.Create(saveFileDialog.FileName));
                break;

            default:
                File.WriteAllText(saveFileDialog.FileName, ConvertToTxt(_recognizePasswordListObservableCollection));
                break;
            }
        }