/// <summary> /// 웹페이지를 이동한다. /// </summary> /// <param name="uri"></param> /// <param name="isWait">완료 할 때까지 대기 여부</param> public void Navigate(string uri, bool isWait = false) { try { bool v = ie.Visible; } catch { init_ie(); } ie.Navigate(uri); if (!isWait) { return; } //페이지 로딩시간이 필요하다 while (ie.Busy) { Thread.Sleep(100); } }
/// <summary> /// http://devdistrict.com/codedetails.aspx?A=416 /// </summary> public static void OpeningInternetExplorer() { //Create a reference to IE SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorer(); //Make it visible so we can see it ie.Visible = true; object o = null; //Navigate to a web page ie.Navigate("http://devdistrict.com", ref o, ref o, ref o, ref o); }
public static object visit(object ast, TextWriter w, string[] args, MessageWriter msg) { int nf = 0; string oname = null; foreach (string s in args) { if (s.StartsWith("-file=")) { oname = s.Substring(6); nf++; } } if (oname == null) { oname = Path.GetTempFileName(); File.Delete(oname); oname = Path.ChangeExtension(oname, ".htm"); } try { TextWriter wr = new StreamWriter(oname); if (oname.EndsWith(".htm") || oname.EndsWith(".html")) { Debug.DumpAllHTML(ast, wr); } else { Debug.DumpAll(ast, wr); } wr.Close(); } catch (Exception e) { msg.Error("can't write \"{0}\" ({1})", oname, e.ToString()); return(ast); } if (nf == 0) { try { object o = null; IWebBrowserApp ie = new SHDocVw.InternetExplorer(); ie.Visible = true; ie.Navigate(oname, ref o, ref o, ref o, ref o); } catch (Exception e) { msg.Error("can't launch Internet Explorer ({0})", e.ToString()); } } return(ast); }
internal void OpenLinkInNewWindow(string url) { switch (type) { case BrowserType.IExplore: { NewWindowWasOpened = true; var iExplorer = new SHDocVw.InternetExplorer { ToolBar = 0, StatusBar = false, MenuBar = false, Width = width, Height = height, Visible = true }; iExplorer.Navigate(url); NewWindowHWND = new IntPtr(iExplorer.HWND); BringWindowToTop(NewWindowHWND); } break; case BrowserType.Chrome: case BrowserType.Firefox: { NewWindowWasOpened = true; var args = string.Format(GetNewWindowOption(), url); StartBrowser(args); ResizeWindow(); } break; default: { var process = Process.Start(url); if (process != null) { NewWindowHWND = process.MainWindowHandle; } } break; } }
static void Main(string[] args) { int counter = 0; string found = ""; // Set up your credentials (https://apps.twitter.com) Auth.SetUserCredentials("", "", "", ""); //Throw in twitter keys here var tweets = Timeline.GetUserTimeline("dumpmon"); SHDocVw.InternetExplorer IE = new SHDocVw.InternetExplorer(); IE.Navigate("google.com"); List <string> searchTerms = new List <String>(); var tweetArray = tweets.ToArray(); while (IE.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE) { Console.Write("Setting up environment"); System.Threading.Thread.Sleep(500); Console.Clear(); Console.Write("Setting up environment."); System.Threading.Thread.Sleep(500); Console.Clear(); Console.Write("Setting up environment.."); System.Threading.Thread.Sleep(500); Console.Clear(); Console.Write("Setting up environment..."); System.Threading.Thread.Sleep(500); Console.Clear(); } while (!searchTerms.Contains("done")) { Console.WriteLine("Enter a term to search for or type '<>' to start the search. Type '!!' to exit"); string text = Console.ReadLine(); if (text != "<>" && text != "!!") { searchTerms.Add(text); } else if (text == "!!") { Environment.Exit(0); } else { searchTerms.Add("done"); } } searchTerms.Remove("done"); for (int i = 0; i < tweets.Count(); i++) { string url = tweetArray[i].ToString(); url = url.Remove(23, url.Length - 23); //Trim tweet to just URL IE.Navigate(url); while (IE.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE) { } //Gather HTML for checking mshtml.IHTMLDocument2 doc = IE.Document as mshtml.IHTMLDocument2; for (int j = 0; j < searchTerms.Count; j++) { if (doc.body.innerText.Contains(searchTerms[j])) { Console.WriteLine(url + " DETAILS FOUND!"); Console.WriteLine("DETAILS FOUND!"); found = found + (url + "\n"); counter++; } else { Console.WriteLine(url + " Checked against check data #" + (j + 1) + "------> 0 hits"); } } } Console.WriteLine("\n\n"); Console.Write(counter + " hit/s "); Console.WriteLine(found); if (found != "") { string strPath = Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory); string strDate = DateTime.Today.Date.ToString("yyyy-MM-dd"); System.IO.File.WriteAllText(strPath + "\\TwitterCrawlerLog_" + strDate + ".text", found); Console.Write("Log file written to desktop"); } Console.Read(); }