Exemple #1
0
 public MonitorWebStep(String name = null, int sleepTime = 500, int maxCount = 120, WebValidator validator = null)
     : base(name)
 {
     this.SleepTime = sleepTime;
     this.MaxCount  = maxCount;
     this.Validator = validator;
 }
Exemple #2
0
 public AbstractWebAction(bool waitForEvent = false, WebValidator validator = null, WebValidator canDoValidator = null, WebValidator shouldWaitValidator = null)
 {
     this.IsWaitForEvent = waitForEvent;
     Validator           = validator;
     CanDoValidator      = canDoValidator;
     ShouldWaitValidator = shouldWaitValidator;
 }
Exemple #3
0
        private void Submit_Click(object sender, EventArgs e)
        {
            WebValidator test = new WebValidator();

            try
            {
                ProcessLink(WebURL.Text, PathDisplay.Text);

                DialogResult dialogResult = MessageBox.Show("Continue Ripping Manga?", "Manga Ripper", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    return;
                }
                else if (dialogResult == DialogResult.No)
                {
                    Application.Exit();
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }

            return;
        }
Exemple #4
0
 public ClickWebStep(String name = null, HtmlElementLocator locator = null, string method = "click", WebValidator validator = null)
     : base(name)
 {
     this.ElementLocator = locator;
     this.Method         = method;
     this.Validator      = validator;
 }
Exemple #5
0
 public FormWebStep(String name = null, HtmlElementLocator locator = null, Dictionary<string, string> parameters = null, string method = "submit", WebValidator validator = null, WebCallback preElementLocatorCallback = null)
     : base(name)
 {
     this.ElementLocator = locator;
     this.Method = method;
     this.Parameters = parameters;
     this.Validator = validator;
     this.PreElementLocatorCallback = preElementLocatorCallback;
 }
Exemple #6
0
 public TimedWebAction(WebValidator validator = null, WebValidator canDoValidator = null, WebValidator shouldWaitValidator = null, bool waitForEvent = false)
     : base(waitForEvent, validator, canDoValidator, shouldWaitValidator)
 {
 }
Exemple #7
0
 public SimpleWebAction(WebStep step = null, WebValidator validator = null, WebValidator canDoValidator = null, WebValidator shouldWaitValidator = null, bool waitForEvent = false)
     : base(waitForEvent, validator, canDoValidator, shouldWaitValidator)
 {
     Step = step;
 }
Exemple #8
0
 public TimedProxyWebValidator(WebValidator validator = null)
 {
     Validator = validator;
 }
Exemple #9
0
 public TimedProxyWebStep(WebStep webStep = null, WebValidator validator = null)
     : base()
 {
     Step = webStep;
     this.Validator = validator;
 }
Exemple #10
0
 public TimedProxyWebStep(WebStep webStep = null, WebValidator validator = null)
     : base()
 {
     Step           = webStep;
     this.Validator = validator;
 }
Exemple #11
0
 public FormWebStep(String name = null, HtmlElementLocator locator = null, Dictionary <string, string> parameters = null, string method = "submit", WebValidator validator = null, WebCallback preElementLocatorCallback = null)
     : base(name)
 {
     this.ElementLocator            = locator;
     this.Method                    = method;
     this.Parameters                = parameters;
     this.Validator                 = validator;
     this.PreElementLocatorCallback = preElementLocatorCallback;
 }
Exemple #12
0
 public UrlWebStep(String name = null, String urlOrContextKey = null, WebValidator validator = null)
     : base(name)
 {
     this.UrlOrContextKey = urlOrContextKey;
     this.Validator       = validator;
 }
        public void Process()
        {
            loadFromSourceConfig();

            // make sure web source is available
            WebValidator webVal = new WebValidator();

            // ensure link is valid
            if (!webVal.isValidURL(inputLink))
            {
                throw new Exception(ErrorMsg.INVALID_WEB_LINK);
            }

            // create process tree
            string link             = inputLink;
            int    currChapterCount = 1;
            int    currPageNum      = 1;

            MangaHolder  currManga   = new MangaHolder();
            MangaChapter currChapter = new MangaChapter();

            while (!String.IsNullOrEmpty(link))
            {
                HtmlDocument currentDoc = getPageSource(link);

                string lastPageURL     = link;
                string nextPageElement = getElementFromKey(currentDoc.DocumentNode, new Queue <KeyValuePair <string, int> >(nextPageKey), "href");

                string nextPageURL    = getURL(getElementFromKey(currentDoc.DocumentNode, new Queue <KeyValuePair <string, int> >(nextPageKey), "href"), link);
                string chapterPageURL = getURL(getElementFromKey(currentDoc.DocumentNode, new Queue <KeyValuePair <string, int> >(chapterPageKey), "href"), link);
                string imageSrcURL    = getURL(getElementFromKey(currentDoc.DocumentNode, new Queue <KeyValuePair <string, int> >(imgPageKey), "content"), link);

                // If theres a chapter configuration make there we didnt miss any chapters
                if (nextChapterPageKey.Count > 0 && nextPageElement != null && nextPageElement.Equals("javascript:void(0);"))
                {
                    nextPageURL = getURL(getElementFromKey(currentDoc.DocumentNode, new Queue <KeyValuePair <string, int> >(nextChapterPageKey), "href"), link);
                }
                if (
                    !String.IsNullOrEmpty(lastPageURL) &&
                    !String.IsNullOrEmpty(nextPageURL) &&
                    !String.IsNullOrEmpty(imageSrcURL) &&
                    !String.IsNullOrEmpty(chapterPageURL)
                    )
                {
                    // Base Case
                    if (!currManga.ContainsChapter(chapterPageURL))
                    {
                        currPageNum = 1;

                        MangaChapter chapter = new MangaChapter(chapterPageURL);
                        chapter.TryAddPage(new MangaPage(imageSrcURL, lastPageURL, nextPageURL, chapterPageURL, currPageNum));
                        chapter.relativeChapterNum = currChapterCount;

                        currChapterCount++;
                        //chapter.AddPage(new MangaPage(imageSrcURL, lastPageURL, nextPageURL, chapterPageURL, currPageNum));
                        currManga.TryAddChapter(chapter);
                    }
                    else
                    {
                        currManga.AddToExistingChapter(chapterPageURL, new MangaPage(imageSrcURL, lastPageURL, nextPageURL, chapterPageURL, currPageNum));
                    }

                    currPageNum++;
                }

                link = nextPageURL;
            }

            //Create folder in temp
            string tempPath = Path.GetTempPath();

            if (String.IsNullOrEmpty(tempPath))
            {
                throw new Exception(ErrorMsg.INVALID_TEMP_FOLDER_PATH);
            }

            tempPath = tempPath + DateTime.Now.Ticks;
            // DateTime.Now.Ticks will make the folder path unique af
            Directory.CreateDirectory(tempPath);
            //

            Console.WriteLine("Temp Path: " + tempPath);
            string mangaPath = tempPath;
            string chapterFolderPath;
            string fileName;

            foreach (KeyValuePair <String, MangaChapter> chapter in currManga.chapters)
            {
                chapterFolderPath = tempPath + "\\" + chapter.Value.relativeChapterNum.ToString();
                Directory.CreateDirectory(chapterFolderPath);
                foreach (List <MangaPage> pages in chapter.Value.pages.Values)
                {
                    foreach (MangaPage page in pages)
                    {
                        fileName = chapterFolderPath + "\\" + page.relativePageNum + ".jpg";

                        Console.WriteLine("Downloading src: " + page.imgSrc);
                        using (WebClient client = new WebClient())
                        {
                            client.DownloadFile(page.imgSrc, fileName);
                        }
                    }
                }
            }

            string zipName = folderPath + "\\" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".zip";

            using (ZipFile zip = new ZipFile())
            {
                zip.AddDirectory(tempPath);
                zip.Save(zipName);
            }

            System.IO.DirectoryInfo di = new DirectoryInfo(tempPath);

            foreach (FileInfo file in di.GetFiles())
            {
                file.Delete();
            }
            foreach (DirectoryInfo dir in di.GetDirectories())
            {
                dir.Delete(true);
            }

            //test(getPageSource(inputLink), inputLink);
            System.Windows.Forms.MessageBox.Show("Finished downloading images. Please locate to " + folderPath + " for the manga ripped.");

            return;
        }
 public TimedProxyWebValidator(WebValidator validator = null)
 {
     Validator = validator;
 }
Exemple #15
0
 public ClickWebStep(String name = null, HtmlElementLocator locator = null, string method = "click", WebValidator validator = null)
     : base(name)
 {
     this.ElementLocator = locator;
     this.Method = method;
     this.Validator = validator;
 }
Exemple #16
0
 public UrlWebStep(String name = null, String url = null, WebValidator validator = null)
     : base(name)
 {
     this.Url       = url;
     this.Validator = validator;
 }
Exemple #17
0
 public MonitorWebStep(String name = null, int sleepTime = 500, int maxCount = 120, WebValidator validator = null)
     : base(name)
 {
     this.SleepTime = sleepTime;
     this.MaxCount = maxCount;
     this.Validator = validator;
 }
Exemple #18
0
 public UrlWebStep(String name = null, String url = null, WebValidator validator = null)
     : base(name)
 {
     this.Url = url;
     this.Validator = validator;
 }
Exemple #19
0
 public UrlWebStep(String name = null, String urlOrContextKey = null, WebValidator validator = null)
     : base(name)
 {
     this.UrlOrContextKey = urlOrContextKey;
     this.Validator = validator;
 }
Exemple #20
0
        /// <summary>
        /// Parses the wikipedia.
        /// </summary>
        /// <param name="searchWord">The search word.</param>
        /// <param name="outputType">Type of the output.</param>
        /// <param name="parseType">Type of the parse.</param>
        public void ParseWikipedia(string searchWord, WikiOutputType outputType, WikiParseType parseType)
        {
            string        uri = "";
            StringBuilder str = new StringBuilder();

            switch (parseType)
            {
            case WikiParseType.Article:
                this.lblTitle.Text = "Wikipedia Artikel";

                Uri webUri;
                Uri downloadUri;

                if (WebValidator.IsWebAddress(searchWord))
                {
                    // http://de.wikipedia.org/wiki/Die_Entf%C3%BChrung_der_U-Bahn_Pelham_123
                    //searchWord = searchWord.Substring(searchWord.IndexOf("wiki/") + 5);
                    //uri = WP_URL + string.Format(WP_EXPORT_SCRIPT, searchWord);
                    if (uri.Contains(WP_EXPORT_SCRIPT_ADD))
                    {
                        //uri = searchWord;
                        uri = searchWord.Replace("/wiki/" + WP_EXPORT_SCRIPT_ADD, "/wiki/");
                    }
                    else
                    {
                        //uri = searchWord.Replace("/wiki/", "/wiki/" + WP_EXPORT_SCRIPT_ADD);
                        uri = searchWord;
                    }

                    if (!searchWord.Contains(WP_EXPORT_SCRIPT_ADD))
                    {
                        searchWord = searchWord.Replace("/wiki/", "/wiki/" + WP_EXPORT_SCRIPT_ADD);
                    }

                    webUri      = new Uri(uri);
                    downloadUri = new Uri(searchWord);                            //.Replace("/wiki/", "/wiki/" + WP_EXPORT_SCRIPT_ADD));
                }
                else
                {
                    searchWord = this.ToCamelCase(searchWord);
                    searchWord = searchWord.Replace(' ', '_');

                    if (uri.Contains(WP_EXPORT_SCRIPT_ADD))
                    {
                        uri = WP_URL + searchWord;
                    }
                    else
                    {
                        uri = WP_URL + string.Format(WP_EXPORT_SCRIPT, searchWord);
                    }

                    webUri      = new Uri(WP_URL + searchWord);
                    downloadUri = new Uri(WP_URL + string.Format(WP_EXPORT_SCRIPT, searchWord));
                }

                this.wbResponse.Stop();
                //this.wbResponse = new WebBrowser();
                //this.wbResponse.Url = null;
                this.wbResponse.Url = webUri;
                this.wbResponse.Navigate(webUri);

                WebClient wc = new WebClient();
                wc.Headers.Add("user-agent", "MovieMatic (compatible; .NET 3.5;)");
                string response = wc.DownloadString(downloadUri.AbsoluteUri);

                this.txtResponse.Text = response;

                //this.wbResponse.Refresh(WebBrowserRefreshOption.Completely);
                break;

            case WikiParseType.Search:
                this.lblTitle.Text = "Suchergebnis";

                searchWord = searchWord.Replace(' ', '+');

                uri = WP_URL + string.Format(WP_SEARCH_SCRIPT, searchWord);
                break;

            default:
                break;
            }

            //Stopwatch watch = new Stopwatch();
            //watch.Start();

            //// start request
            //HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri);

            //webRequest.Credentials = CredentialCache.DefaultCredentials;
            ////webRequest.Accept = "text/xml";

            //HttpWebResponse webResponse = null;
            //Stream responseStream = null;

            //try {
            //    webResponse = (HttpWebResponse)webRequest.GetResponse();
            //    responseStream = webResponse.GetResponseStream();

            //    using(StreamReader streamReader = new StreamReader(responseStream)) {
            //        while(!streamReader.EndOfStream) {
            //            str.Append(streamReader.ReadLine());
            //            str.Append("\r\n");
            //        }

            //        //this.txtResponse.Text = str.ToString();
            //    }
            //}
            //catch(WebException webex) {
            //    str.Append("WebException:\r\n");
            //    str.Append(webex.ToString());
            //}
            //catch(Exception ex) {
            //    str.Append("Exception:\r\n");
            //    str.Append(ex.ToString());
            //}
            //finally {
            //    if(responseStream != null) {
            //        responseStream.Close();
            //        responseStream.Dispose();
            //    }

            //    if(webResponse != null) {
            //        webResponse.Close();
            //    }
            //}

            ////watch.Stop();
            ////TimeSpan span = watch.Elapsed;

            ////this.lblRequestTime.Text = string.Format(
            ////    "Request time: {0} - {1}ms ({2} Ticks)",
            ////    span.ToString(),
            ////    watch.ElapsedMilliseconds,
            ////    watch.ElapsedTicks
            ////);

            //// show result
            //this.txtResponse.Text = str.ToString();


            //if(str.Length > 0) {
            //    //this.txtResponse.Text = str.ToString();

            //    switch(parseType) {
            //        case WikiParseType.Article:
            //            this.lbResult.Visible = false;
            //            this.txtResponse.Visible = false;
            //            this.pBrowser.Visible = true;
            //            //this.wbResponse.Visible = true;
            //            this.wbResponse.Show();

            //            if(str.ToString() != Resources.WikipediaText.EmptyExportResult + "\r\n") {
            //                this.btnOpenEditor.Enabled = true;

            //                if(str.ToString().Contains("#REDIRECT")) {
            //                    //  <text xml:space="preserve">#REDIRECT [[Star Trek (2009)]]</text>
            //                    string tmp = str.ToString();
            //                    int start = tmp.IndexOf("<text xml:space=\"preserve\">") + ("<text xml:space=\"preserve\">").Length;
            //                    int end = tmp.IndexOf("</text>", start) - start;
            //                    tmp = tmp.Substring(start, end);
            //                    this.ReOpenDialog(WikipediaParser.ParseRedirect(tmp));
            //                }
            //                else {
            //                    this.txtResponse.Text = str.ToString();
            //                }
            //            }
            //            else {
            //                this.btnOpenEditor.Enabled = false;

            //                this.Cursor = Cursors.WaitCursor;

            //                this.ParseWikipedia(
            //                    searchWord,
            //                    WikiOutputType.Html,
            //                    WikiParseType.Search
            //                );

            //                this.Cursor = Cursors.Default;
            //            }
            //            break;

            //        case WikiParseType.Search:
            //            this.btnOpenEditor.Enabled = false;

            //            this.lbResult.Visible = true;
            //            this.txtResponse.Visible = false;
            //            this.pBrowser.Visible = false;
            //            //this.wbResponse.Visible = false;
            //            this.wbResponse.Hide();

            //            //<!-- Search results fetched via search=[search6], highlight=[search7], interwiki=[search10] in 104 ms -->
            //            //<ul class='mw-search-results'>

            //            string buffer = str.ToString();

            //            if(buffer.Contains("<ul class='mw-search-results'>")) {
            //                int start = buffer.IndexOf("<ul class='mw-search-results'>") + ( "<ul class='mw-search-results'>" ).Length;
            //                int end = buffer.IndexOf("</div><p class='mw-search-pager-bottom'>") - start;

            //                string output = buffer.Substring(start, end);

            //                //</ul>
            //                //</div><p class='mw-search-pager-bottom'>

            //                string[] items = output.Split(new string[] { "<li>" }, StringSplitOptions.RemoveEmptyEntries);

            //                foreach(string item in items) {
            //                    if(item != "\r\n") {
            //                        if(item.Contains("<a href=\"/wiki/")) {
            //                            int linkStart = item.IndexOf("<a href=\"/wiki/") + ( "<a href=\"/wiki/" ).Length;
            //                            int linkEnd = item.IndexOf("\" title=\"") - linkStart;

            //                            int titleStart = item.IndexOf("\">", linkEnd) + ( "\">" ).Length;
            //                            int titleEnd = item.IndexOf("</a>", linkEnd) - titleStart;

            //                            string link = item.Substring(linkStart, linkEnd);
            //                            string title = item.Substring(titleStart, titleEnd);

            //                            Regex textreplace = new Regex("(<[^>]*>)");
            //                            title = textreplace.Replace(title, "");

            //                            this.lbResult.Items.Add(title + " (Wiki Titel: " + link + ")");
            //                        }
            //                    }
            //                }

            //                //<li><a href="/wiki/American_History_X" title="American History X">
            //                //<span class='searchmatch'>American</span> <span class='searchmatch'>History</span> X</a>
            //                //<div class='searchresult'><span class='searchmatch'>American</span> <span class='searchmatch'>History</span> X ist ein Film aus dem Jahre 1998 .  Er beschäftigt sich mit der US-amerikanischen  Neonazi -Szene. Tony Kaye  führte  <b>…</b>
            //                //</div>
            //                //</li>

            //                //this.txtResponse.Text = output;
            //            }
            //            else {
            //                StaticWindows.InfoBox(
            //                    "Es konnte kein Eintrag gefunden werden, bitte ändern Sie Ihre Suchanfrage."
            //                );
            //            }
            //            break;

            //        default:
            //            break;
            //    }
            //}
        }