예제 #1
0
        public bool CheckGfycat(String url)
        {
            try
            {
                ie.Navigate2(url);
                //wb.ReadyState != WebBrowserReadyState.Complete
                while (ie.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
                {
                }
                mshtml.HTMLDocument vidpage = (mshtml.HTMLDocument)ie.Document;

                String title = vidpage.title;


                if (title.Contains("Not Found"))
                {
                    intbroken++;
                    return(false);
                }
                else
                {//Fullplay not currently supported on gfycat
                 //Thread.Sleep(1000);
                 //if (fullplay)
                 //{
                 //    double dur = vid.getAttribute("duration");
                 //    double curtime = vid.getAttribute("currentTime");
                 //    bool past = false;
                 //    while (curtime != dur && (curtime > .5 || !past))
                 //    {
                 //        if (!past && curtime > .5)
                 //        {
                 //            past = true;
                 //        }
                 //        curtime = vid.getAttribute("currentTime");
                 //    }
                 //}
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.Equals("The remote server returned an error: (404) Not Found.") ||
                    ex.Message.Equals("The remote server returned an error: (500) Internal Server Error."))
                {
                    intbroken++;
                    return(false);
                }
                else
                {
                    throw ex;
                }
            }
            return(true);
        }
예제 #2
0
        private static Main(string dirPath)
        {
            // Define Working Directory
            DirectoryInfo dir = new DirectoryInfo(@"C:\fileDump");

            // Define File Type
            foreach (FileInfo finfo in dir.GetFiles("*.html"))
            {
                // Open IE Explorer and Print
                if (Application.Current.Properties["finfo"] != null)
                {
                    string fname = Application.Current.Properties["finfo"].ToString();
                    if (String.IsNullOrEmpty(fname))
                    {
                        fileLabel.Content = "No File Specified";
                    }
                    else
                    {
                        fileLabel.Content = fname;
                        SHDocVw.InternetExplorer IE = new SHDocVw.InternetExplorer();
                        IE.DocumentComplete      += new SHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler(IE_DocumentComplete);
                        IE.PrintTemplateTeardown += new SHDocVw.DWebBrowserEvents2_PrintTemplateTeardownEventHandler(IE_PrintTemplateTeardown);
                        IE.Visible = true;
                        IE.Navigate2(fname);
                    }
                }
            }
        }
예제 #3
0
파일: Browser.cs 프로젝트: zergmk2/openrpa
        public static Browser GetBrowser(string url = null)
        {
            var result = new Browser();

            SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();
            foreach (SHDocVw.InternetExplorer _ie in shellWindows)
            {
                var filename = System.IO.Path.GetFileNameWithoutExtension(_ie.FullName).ToLower();

                if (filename.Equals("iexplore"))
                {
                    // Log.Debug(string.Format("Web Site : {0}", _ie.LocationURL));
                    try
                    {
                        result.wBrowser = _ie as SHDocVw.WebBrowser;
                        // result.IE = _ie;
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "");
                    }
                }
            }
            if (result.wBrowser == null && !string.IsNullOrEmpty(url))
            {
                object m = null;
                SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorer();
                // Open the URL
                ie.Navigate2(url, ref m, ref m, ref m, ref m);
                ie.Visible = true;
                var sw = new Stopwatch();
                sw.Start();
                while (result.wBrowser == null)
                {
                    try
                    {
                        var doc     = ie.Document as MSHTML.HTMLDocument;
                        var timeout = TimeSpan.FromSeconds(5);
                        while (sw.Elapsed < timeout && doc.readyState != "complete" && doc.readyState != "interactive")
                        {
                            // Log.Debug("pending complete, readyState: " + doc.readyState);
                            System.Threading.Thread.Sleep(100);
                        }
                        result.wBrowser = ie as SHDocVw.WebBrowser;
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            if (result.wBrowser == null)
            {
                return(null);
            }
            result.Document = result.wBrowser.Document as MSHTML.HTMLDocument;
            result.title    = result.Document.title;
            result.findPanel();
            return(result);
        }
예제 #4
0
        public static void StartBrowser()
        {
            SHDocVw.InternetExplorer IE = new SHDocVw.InternetExplorer();
            object Empty = 0;
            object URL   = Program.BeaconURL + "relay/";

            IE.Visible = false;
            IE.Navigate2(ref URL, ref Empty, ref Empty, ref Empty, ref Empty);
        }
예제 #5
0
        private async Task <QbResponse> WinApiAsync(string url, QbConfig qbConfig)
        {
            try
            {
                _qbResponse      = new QbResponse();
                _qbConfiguration = qbConfig;



                var    IE  = new SHDocVw.InternetExplorer();
                object URL = url;
                IE.ToolBar   = 0;
                IE.StatusBar = false;
                IE.MenuBar   = false;
                IE.Width     = 1022;
                IE.Height    = 782;
                IE.Visible   = true;
                IE.Navigate2(url, null, null, null, null);
                if (_qbConfiguration.SelectedMode == QbConfig.AppMode.Console)
                {
                    Console.WriteLine("Begin Loading...");
                }
                while (IE.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
                {
                    if (_qbConfiguration.SelectedMode == QbConfig.AppMode.Console)
                    {
                        Console.WriteLine("Loading the web page...");
                    }
                    if (IE.ReadyState == SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
                    {
                        IE.NavigateComplete2 += IE_NavigateComplete2;
                        if (_qbConfiguration.SelectedMode == QbConfig.AppMode.Console)
                        {
                            Console.WriteLine("Loaded!");
                        }
                        _internetExplorer = IE;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            while (true)
            {
                if (_isReadytoExit)
                {
                    return(_qbResponse);
                }
            }
            ;
        }
예제 #6
0
        public static void OpenIE()
        {
            Proxies.UnsetProxy();
            List<string> ipList = new List<string>();
            string ids = null;
            bool isCompleted = false;
            EventHandlers everHandlers = new EventHandlers();
            SHDocVw.InternetExplorer ieExplorer = new SHDocVw.InternetExplorer();
            object Empty = 0;
            object URL = "http://hao.360.cn/?src=lm&ls=n1b07c70297";
            ieExplorer.BeforeNavigate2 += new SHDocVw.DWebBrowserEvents2_BeforeNavigate2EventHandler(everHandlers.OnBeforeNavigate2);
            ieExplorer.Visible = true;
            ieExplorer.Navigate2(ref URL, ref Empty, ref Empty, ref Empty, ref Empty);
            ieExplorer.DocumentComplete += delegate
            {
                //var documentClass = ieExplorer.Document;
                //// mshtml.HTMLDocumentClass
                //ids = documentClass.IHTMLDocument2_body.innerHTML;
                isCompleted = true;
            };
            while (true)
            {
                if (isCompleted)
                {
                    break;

                }
            }
            if (isCompleted)
            {
                mshtml.IHTMLDocument2 doc2 = (mshtml.IHTMLDocument2)ieExplorer.Document;
                //mshtml.IHTMLElementCollection inputs = (mshtml.IHTMLElementCollection)doc2.all.tags("INPUT");
                //mshtml.HTMLInputElement input1 = (mshtml.HTMLInputElement)inputs.item("word", 0);
                //input1.value = "刘德华";
                mshtml.IHTMLElementCollection ccCollection = doc2.all.tags("A");

                //mshtml.IHTMLElement element2 = (mshtml.IHTMLElement)ccCollection;   //25新浪,73唯品会
                //int all = ccCollection.length;
                //element2.click();
                int i=0;
            }
            Thread.Sleep(5000);
            ieExplorer.Quit();

            System.Diagnostics.Process[] myProcesses;
            myProcesses = System.Diagnostics.Process.GetProcessesByName("IEXPLORE");
            foreach (System.Diagnostics.Process instance in myProcesses)
            {
                instance.CloseMainWindow();
            }
        }
예제 #7
0
        public void checklink(int x)
        {
            string link   = alllinks[x].ToString();
            string source = alllinksource[x].ToString();

            bool working = false;

            try
            {
                working = CheckVidImage(link);
            }
            catch (Exception ex)
            {
                ie = null;
                Thread.Sleep(1500);
                Process[] IEWindows = Process.GetProcessesByName("IEXPLORE");
                for (int p = 0; p < IEWindows.Length; p++)
                {
                    try
                    {
                        Process curprocc = IEWindows[p];
                        if (!curprocc.HasExited)
                        {
                            curprocc.Kill();
                        }
                    }
                    catch (Exception killex)
                    {
                    }
                }

                ie         = new SHDocVw.InternetExplorer();
                ie.Visible = true;
                ie.Navigate2("www.streamable.com");
                try
                {
                    working = CheckVidImage(link);
                }
                catch (Exception exx)
                {
                    throw exx;
                }
            }

            if (!working)
            {
                output.WriteLine("LINK: " + link + ", SOURCE: " + source);
            }
        }
예제 #8
0
파일: IE.cs 프로젝트: comseung18/IEAuto
        public int Browse(string url)
        {
            object ourl = url;

            try
            {
                ie.Navigate2(ref ourl);
                Wait();
            }
            catch (Exception e)
            {
                LastErrorMsg = e.Message;
                return(-1);
            }
            return(0);
        }
        static void Main(string[] args)
        {
            var IE = new SHDocVw.InternetExplorer();

            object URL = "http://google.com/";

            IE.ToolBar    = 0;
            IE.StatusBar  = true;
            IE.MenuBar    = true;
            IE.AddressBar = true;

            IE.Visible = true;
            ShowWindow((IntPtr)IE.HWND, 3);
            IE.Navigate2(ref URL);
            //ieOpened = true;
        }
예제 #10
0
        //다른 시스템 연결 버튼 클릭시 (POST 방식)
        private void btn_Click(object sender, EventArgs e)
        {
            String url           = String.Empty;
            string str_sendvalue = "MGS_USERID=" + _userId + "&MGS_PASS="******"btn_webHard":
                url           = @"http://Webfile.korcham.net/ssopage_post.php";
                str_sendvalue = "id=" + _userId + "&pass="******"btn_hompage":
                url = "http://license.korcham.net";
                break;

            case "btn_mgs":
                url           = @"https://mgsssl.korcham.net";
                str_sendvalue = "MGS_USERID=" + _userId + "&MGS_PASS="******"btn_role":
                url = "http://license.korcham.net/kor/privacy/roleInfo.jsp";
                break;

            case "btn_schedule":
                url = "http://license.korcham.net/ct/examSchedule.do";
                break;

            default:
                break;
            }
            SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorer();

            object vFlags       = null;
            object vTargetFrame = null;
            object vUrl         = url;
            object vHeaders     = "Content-Type: application/x-www-form-urlencoded" + Convert.ToChar(10) + Convert.ToChar(13);
            var    cPostData    = str_sendvalue;
            object vPost        = ASCIIEncoding.ASCII.GetBytes(cPostData);

            ie.Visible = true;
            ie.Navigate2(ref vUrl, ref vFlags, ref vTargetFrame, ref vPost, ref vHeaders);
        }
예제 #11
0
        // 작업 결과 값을 반환할 경우 CodeActivity<TResult>에서 파생되고
        // Execute 메서드에서 값을 반환합니다.
        protected override void Execute(CodeActivityContext context)
        {
            // 텍스트 입력 인수의 런타임 값을 가져옵니다.
            string text = context.GetValue(this.Text);

            object sUrl = msURL;

            if (mBrowserType == InternetBrowserType.IE)
            {
                SHDocVw.InternetExplorer IE;

                IE = new SHDocVw.InternetExplorer();

                object Empty = new object();

                IE.Visible = true;
                IE.Left    = 0;
                IE.Top     = 0;

                if (mWindowState == WindowStateType.Maxmize)
                {
                    CommonUtil.ShowWindow((IntPtr)IE.HWND, (int)CommonUtil.ShowWindowType.SW_MAXIMIZE);
                }

                if (mWindowState == WindowStateType.Minimize)
                {
                    CommonUtil.ShowWindow((IntPtr)IE.HWND, (int)CommonUtil.ShowWindowType.SW_MINIMIZE);
                }

                IE.Navigate2(ref sUrl);

                while (IE.Busy == true || IE.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
                {
                    System.Threading.Thread.Sleep(100);
                }


                //output
                this.ResultHandle.Set(context, (IntPtr)IE.HWND);
                this.ResultBool.Set(context, true);
            }
            else
            {
                MessageBox.Show("Not support");
            }
        }
예제 #12
0
        public static List<string> OperateIE(string url = "")
        {
            Proxies.UnsetProxy();
            List<string> ipList = new List<string>();
            string ids = null;
            bool isCompleted = false;
            EventHandlers everHandlers = new EventHandlers();
            SHDocVw.InternetExplorer ieExplorer = new SHDocVw.InternetExplorer();
            object Empty = 0;
            object URL = "http://vxer.daili666.com/ip/?tid=555950095890637&num=10&ports=80&filter=on";
            ieExplorer.BeforeNavigate2 +=
                new SHDocVw.DWebBrowserEvents2_BeforeNavigate2EventHandler(everHandlers.OnBeforeNavigate2);
            ieExplorer.Visible = false;
            ieExplorer.Navigate2(ref URL, ref Empty, ref Empty, ref Empty, ref Empty);
            ieExplorer.DocumentComplete += delegate
            {
                var documentClass = ieExplorer.Document;
                // mshtml.HTMLDocumentClass
                ids = documentClass.IHTMLDocument2_body.innerHTML;
                isCompleted = true;
            };
            while (true)
            {
                if (isCompleted)
                {
                    break;

                }
            }
            if (ids != null)
            {
                ids = ids.Substring(ids.IndexOf('>') + 1, ids.LastIndexOf('<') - 5);
                StringReader s = new StringReader(ids);

                while (s.Peek() > 0)
                {
                    var s1 = s.ReadLine();
                    ipList.Add(s1);
                }
                s.Close();
            }
            ieExplorer.Quit();
            return ipList;
        }
    public MainWindow()
    {
        InitializeComponent();

        if (Application.Current.Properties["ArgFileName"] != null)
        {
            string fname = Application.Current.Properties["ArgFileName"].ToString();
            if (String.IsNullOrEmpty(fname))
            {
                fileLabel.Content = "No File Specified";
            }
            else
            {
                fileLabel.Content = fname;
                SHDocVw.InternetExplorer IE = new SHDocVw.InternetExplorer();
                IE.DocumentComplete      += new SHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler(IE_DocumentComplete);
                IE.PrintTemplateTeardown += new SHDocVw.DWebBrowserEvents2_PrintTemplateTeardownEventHandler(IE_PrintTemplateTeardown);
                IE.Visible = true;
                IE.Navigate2(fname);
            }
        }
    }
        static void Main(string[] args)
        {
            var ie = new SHDocVw.InternetExplorer();
            // Ensure that ie.Quit() is called at the end via the destructor
            var raii = new IE_RAII(ie);

            // Just so you can see what's going on for now
            ie.Visible = true;
            ie.Navigate2("http://www.wellsfargo.com");
            var document = GetDocument(ie);
            var userid   = document.getElementById("userid");

            userid.Value = "billy.everyteen";
            var password = document.getElementById("password");

            password.Value = "monroebot";
            var form = document.Forms("signon");

            form.Submit();
            // Hang out for a while...
            System.Threading.Thread.Sleep(10000);
        }
예제 #15
0
        public sealed override async Task <Tuple <string, LinkFetchResult> > GetSourceLink(string url)
        {
            var ie = new IE();

            ie.Navigate2(url);

            while (ie.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
            {
            }

            SHDocVw.WebBrowser browser = ((SHDocVw.WebBrowser)ie);
            HTMLDocument       doc     = ((HTMLDocument)browser.Document);
            IHTMLElement       button  = doc.getElementById("btn_download");

            await Pause(5000); //Wait 5 Seconds.

            button.click();    //Click button

            string tempFile = $"{System.IO.Path.GetTempPath()}{Guid.NewGuid().ToString()}.lf.html";

            await JavaScriptProcessingTime(); //Wait 15 seconds.

            using (var output = new FileStream(tempFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite))
            {
                byte[] buffer = ASCIIEncoding.UTF8.GetBytes(((HTMLDocument)browser.Document).documentElement.outerHTML);
                await output.WriteAsync(buffer, 0, buffer.Length);
            }

            UpdateStatus("Scanning Web page after link...");

            var   line  = string.Empty;
            var   input = new StreamReader(tempFile);
            Match match = null;

            while ((line = input.ReadLine()) != null) //Scan file for link.
            {
                if (line == "")
                {
                    continue;
                }
                match = _bourceUrlPattern.Match(line);

                if (match.Success)
                {
                    break;
                }
            }

            var sourceUrl = string.Empty;
            var response  = LinkFetchResult.SUCCESSFULL;

            if (match.Success)
            {
                sourceUrl = match.Groups[2].Value;
            }
            else
            {
                response = LinkFetchResult.FAILED;
            }
            return(new Tuple <string, LinkFetchResult>(sourceUrl, response));
        }
예제 #16
0
        public void checkPostNSFW(String url)
        {
            output.WriteLine("~~~NSFW Thread (maybe) detected, count and results may be off.  For best results, temporarily turn off NSFW/Spoilers~~~");
            WebClient client  = new WebClient();
            string    webpage = client.DownloadString(url);

            try
            {
                int indexing = webpage.IndexOf("<title");
                if (indexing != -1)
                {
                    webpage = webpage.Substring(indexing);
                }
                else
                {
                    return;
                }
                indexing = webpage.ToLower().IndexOf("what are your thoughts? log in or sign up");
                if (indexing == -1)
                {
                    indexing = webpage.ToLower().IndexOf("commentSort--sortpicker");
                    if (indexing == -1)
                    {
                        indexing = webpage.ToLower().IndexOf("commentsignupbar");
                        if (indexing == -1)
                        {
                            indexing = webpage.ToLower().IndexOf("link-save-button");
                            if (indexing == -1)
                            {
                                indexing = webpage.Length - 10;
                            }
                        }
                    }
                }//
                webpage = webpage.Substring(0, indexing);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            //href=\"https://imgur.com/a/0Eiow\">barely able to avoid a direct hit</a>
            while (webpage.IndexOf("href=\\\"") != -1)
            {//\\n\\n*
                String link;
                try
                {
                    webpage = webpage.Substring(webpage.IndexOf("href=\\\""));
                    link    = webpage.Substring(1, webpage.IndexOf("\\u003C/a"));
                    inttotal++;
                }
                catch (Exception ex)
                {
                    throw ex;
                }

                //"href=\"https://streamable.com/i2m7p\">melt cars<"
                string vidurl = "";

                try
                { //"href=\"https://streamable.com/4kudv\" title=\"Parasites Lost\">Correctly identifies sinus anatomy<"
                    vidurl = link.Substring(link.IndexOf("\"") + 1);
                    vidurl = vidurl.Substring(0, vidurl.IndexOf("\\"));
                    if (vidurl.Contains("\" title="))
                    {
                        vidurl = vidurl.Substring(0, vidurl.IndexOf("\" title="));
                    }
                    if (makelist != "" && vidurl.Contains(makelist))
                    {
                        if (!alllinks.Contains(vidurl))
                        {
                            alllinks.Add(vidurl);
                            alllinksource.Add(url.Substring(56));
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                bool working = false;
                try
                {
                    working = CheckVidImage(vidurl);
                }
                catch (Exception ex)
                {
                    ie = null;
                    Thread.Sleep(1500);
                    Process[] IEWindows = Process.GetProcessesByName("IEXPLORE");
                    for (int p = 0; p < IEWindows.Length; p++)
                    {
                        try
                        {
                            Process curprocc = IEWindows[p];
                            if (!curprocc.HasExited)
                            {
                                curprocc.Kill();
                            }
                        }
                        catch (Exception killex)
                        {
                        }
                    }

                    ie         = new SHDocVw.InternetExplorer();
                    ie.Visible = true;
                    ie.Navigate2("www.streamable.com");
                    try
                    {
                        working = CheckVidImage(vidurl);
                    }
                    catch (Exception exx)
                    {
                        throw exx;
                    }
                }

                if (!working)
                {
                    output.WriteLine("LINK: " + vidurl + ", FULL TEXT: " + link);
                }

                try
                {
                    webpage = webpage.Substring(link.Length);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            int blar = 8;
        }
예제 #17
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            txtStatus.Text = "Working";
            imagelinks.Clear();
            vidlinks.Clear();
            posts.Clear();
            alllinks.Clear();
            alllinksource.Clear();
            sublinks.Clear();
            LoadConfig();
            int j = 0;

            try
            {
                ie         = new SHDocVw.InternetExplorer();
                ie.Visible = true;
                ie.Navigate2("www.streamable.com");
                output = new StreamWriter("output.txt");

                if (threadmode)
                {
                    loadPosts();
                    if (startlink != "")
                    {
                        cur = posts.IndexOf(startlink);
                    }
                    while (intcount < posts.Count)
                    {
                        txtStatus.Text = "Checking " + posts[cur].ToString();
                        if (intcount == 22)
                        {
                            string blagds = "HI";
                        }
                        if (cur > posts.Count - 1)
                        {
                            if (loop)
                            {
                                cur = 0;
                            }
                            else
                            {
                                finishOutput();
                                WriteConfig();
                                txtStatus.Text = "Finished";
                                return;
                            }
                        }
                        checkPost(posts[cur].ToString());
                        cur++;
                        intcount++;
                    }
                }
                else
                {
                    loadLinks();
                    for (j = 0; j < alllinks.Count; j++)
                    {
                        if (j % 100 == 0)
                        {
                            txtStatus.Text = "Checking #" + j;
                        }
                        checklink(j);
                        inttotal++;
                    }
                }
            }
            catch (Exception ex)
            {
                if ((intcount != posts.Count - 1) && threadmode)
                {
                    startlink = posts[cur].ToString();
                }
                else if (!threadmode)
                {
                    startlink = alllinks[j].ToString();
                }
            }
            finishOutput();
            WriteConfig();
            if (makelist != "")
            {
                StreamWriter sw = new StreamWriter("links.txt");
                for (int x = 0; x < alllinks.Count; x++)
                {
                    sw.WriteLine(alllinks[x] + "\t" + alllinksource[x]);
                }
                sw.Close();
            }
            if (intsubview > 0)
            {
                StreamWriter sw = new StreamWriter("subviews.txt");
                for (int x = 0; x < sublinks.Count; x++)
                {
                    sw.WriteLine(sublinks[x] + "\tN/A");
                }
                sw.Close();
            }
            Process[] IEWindows = Process.GetProcessesByName("IEXPLORE");
            for (int p = 0; p < IEWindows.Length; p++)
            {
                try
                {
                    Process curprocc = IEWindows[p];
                    if (!curprocc.HasExited)
                    {
                        curprocc.Kill();
                    }
                }
                catch (Exception ex)
                {
                }
            }
            txtStatus.Text = "Finished";
            MessageBox.Show("Kyr's bot is finished");
        }
 /// <summary>
 /// Open url
 /// </summary>
 /// <param name="url"></param>
 /// <param name="frame"></param>
 public void OpenUrl(string url, string frame = "")
 {
     isLoading = true;
     internetExplorer.Navigate2(url, ref missing, frame, ref missing, ref missing);
 }
예제 #19
0
 internal static void OpenInternetExplorerTabs(List<string> urls)
 {
     if (urls.Any())
     {
         var ie = new SHDocVw.InternetExplorer();
         ie.Navigate2(urls[0]);
         ie.Width = Screen.PrimaryScreen.WorkingArea.Width;
         ie.Height = Screen.PrimaryScreen.WorkingArea.Height;
         ie.Left = ie.Top = 0;
         for (var i = 1; i < urls.Count; i++)
             ie.Navigate2(urls[i], 0x800);
         ie.Visible = true;
     }
 }
예제 #20
0
        public sealed override async Task <Tuple <string, LinkFetchResult> > GetSourceLink(string url)
        {
            var ie = new IE();

            ie.Navigate2(url);

            while (ie.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
            {
            }

            SHDocVw.WebBrowser browser = ((SHDocVw.WebBrowser)ie);
            HTMLDocument       doc     = ((HTMLDocument)browser.Document); //Get Document

            IHTMLElementCollection searchHash = (IHTMLElementCollection)doc.getElementsByName("hash");

            string hash      = string.Empty;
            string timestamp = string.Empty;

            foreach (IHTMLElement element in searchHash)
            {
                if (element == null)
                {
                    break;
                }
                if ((string)element.getAttribute("name") == "hash")
                {
                    hash = element.getAttribute("value");
                }
            }

            IHTMLElementCollection searchTimestamp = (IHTMLElementCollection)doc.getElementsByName("timestamp");

            foreach (IHTMLElement element in searchTimestamp)
            {
                if (element == null)
                {
                    break;
                }
                if ((string)element.getAttribute("name") == "timestamp")
                {
                    timestamp = element.getAttribute("value");
                }
            }

            /* PREPARE POST DATA */

            var stringData = $"hash={HttpUtility.UrlEncode(hash)}&timestamp={HttpUtility.UrlEncode(timestamp)}";
            var byteData   = Encoding.ASCII.GetBytes(stringData);

            /* PREPARE HTTP CLIENT */
            var request = (HttpWebRequest)WebRequest.Create(url);

            request.Method        = "POST";
            request.UserAgent     = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246";
            request.ContentType   = "application/x-www-form-urlencoded";
            request.ContentLength = byteData.Length;

            /* SEND POST DATA ASYNC */

            Stream requestStream = await request.GetRequestStreamAsync();

            await requestStream.WriteAsync(byteData, 0, byteData.Length);

            requestStream.Close();

            /* RECIVE RESPONSE ASYNC */
            var response     = ((HttpWebResponse)await request.GetResponseAsync()).GetResponseStream();
            var streamReader = new StreamReader(response, Encoding.Default);

            var responseString = await streamReader.ReadToEndAsync();

            /* PARSE STRING TO DOC  */
            UpdateStatus("Scanning Web page after link");
            var docTemp = (IHTMLDocument2)doc;

            docTemp.write(responseString);

            /* SEARCH DOWNLOAD LINK */
            var contentElement = GetStreamContent(doc);

            var sourceURL     = string.Empty;
            var fetchResponse = LinkFetchResult.SUCCESSFULL;

            if (contentElement != null)
            {
                UpdateStatus("Starting download...");
                sourceURL = contentElement.getAttribute("data-url"); //Get data-url attribute
            }
            else
            {
                fetchResponse = LinkFetchResult.FAILED;
                UpdateStatus("Source link not found");
            }

            ie.Quit();
            return(new Tuple <string, LinkFetchResult>(sourceURL, fetchResponse));
        }
예제 #21
0
        public void Open(string url)
        {
            //Proxies.UnsetProxy();
            //string ids = null;
            bool isCompleted = false;
            EventHandlers everHandlers = new EventHandlers();
            SHDocVw.InternetExplorer ieExplorer = new SHDocVw.InternetExplorer();
            object Empty = 0;
            object URL = url;
            ieExplorer.BeforeNavigate2 += new SHDocVw.DWebBrowserEvents2_BeforeNavigate2EventHandler(everHandlers.OnBeforeNavigate2);
            ieExplorer.Visible = true;
            ieExplorer.Navigate2(ref URL, ref Empty, ref Empty, ref Empty, ref Empty);
            Timer timer=new Timer(10000);
            timer.AutoReset = false;
            timer.Start();
            timer.Elapsed += delegate { isCompleted = true; };
            ieExplorer.DocumentComplete += delegate
            {
                //var documentClass = ieExplorer.Document;
                //// mshtml.HTMLDocumentClass
                //ids = documentClass.IHTMLDocument2_body.innerHTML;
                isCompleted = true;
            };
            while (true)
            {
                if (isCompleted)
                {
                    break;

                }
            }
            if (isCompleted)
            {
                try
                {
                    if (url.Contains("2345"))
                    {
                        mshtml.IHTMLDocument2 doc2 = (mshtml.IHTMLDocument2) ieExplorer.Document;
                        mshtml.IHTMLElementCollection inputs = (mshtml.IHTMLElementCollection) doc2.all.tags("INPUT");
                        mshtml.HTMLInputElement input1 = (mshtml.HTMLInputElement) inputs.item("word", 0);
                        input1.value = "刘德华";
                        mshtml.IHTMLElementCollection ccCollection = doc2.all.tags("A");
                        int random = (new Random()).Next(25, 73); //25新浪,73唯品会
                        mshtml.IHTMLElement element2 = (mshtml.IHTMLElement) ccCollection.item("2", random);
                        element2.click();
                    }
                    if (url.Contains("360"))
                    {
                        mshtml.IHTMLDocument2 doc2 = (mshtml.IHTMLDocument2) ieExplorer.Document;
                        mshtml.IHTMLElementCollection ccCollection = doc2.all.tags("A");
                        int random = (new Random()).Next(70, 140);
                        mshtml.IHTMLElement element2 = (mshtml.IHTMLElement) ccCollection.item(random);
                        element2.click();
                    }
                }
                catch (Exception)
                {

                }
                finally
                {
                    Thread.Sleep(7000);
                    ieExplorer.Quit();

                    System.Diagnostics.Process[] myProcesses;
                    myProcesses = System.Diagnostics.Process.GetProcessesByName("IEXPLORE");
                    foreach (System.Diagnostics.Process instance in myProcesses)
                    {
                        instance.CloseMainWindow();
                    }
                    CleanIECookics.CleanCookie();
                    Thread.Sleep(7000);
                }
            }
        }