public WebScraperBrowser CreateBrowser(WebScraperDispatcher appDispatcher) { Dispatcher threadDispatcher = null; TaskCompletionSource<bool> threadRunning = new TaskCompletionSource<bool>(); Thread thread = new Thread(new ThreadStart(() => { threadDispatcher = Dispatcher.CurrentDispatcher; threadRunning.SetResult(true); Dispatcher.Run(); })); thread.SetApartmentState(ApartmentState.STA); //thread.IsBackground = true; thread.Start(); threadRunning.Task.Wait(); Func<WebScraperBrowser> func = () => { var browser = new WebScraperBrowser(appDispatcher, threadDispatcher); return browser; }; WebScraperBrowser result = threadDispatcher.Invoke(func) as WebScraperBrowser; return result; }
public DomElement(WebScraperDispatcher dispatcher, string browserID, object comObject) { _dispatcher = dispatcher; _browserID = browserID; _comObject = comObject; _attributes = new DomAttributeCollection(dispatcher, browserID, comObject); }
public TffSourceScraper(WebScraperDispatcher dispatcher) { _dispatcher = dispatcher; _urlBinder = new ModelPropertyBinder(); var tempBinder = _urlBinder.AddChildBinder("urlList", typeof(CollectionPropertyBinderAction), ".MasterTable_TFF_Contents tbody tr"); tempBinder = tempBinder.AddChildBinder(null, typeof(ModelPropertyBinderAction), ""); tempBinder.AddChildBinder("source", typeof(AttributePropertyBinderAction), "td:first a", "href"); var customBinder = tempBinder.AddChildBinder("custom", typeof(ModelPropertyBinderAction), ""); customBinder.AddChildBinder("HomeTeam", typeof(HtmlPropertyBinderAction), "td:nth-child(2) a"); customBinder.AddChildBinder("AwayTeam", typeof(HtmlPropertyBinderAction), "td:nth-child(4) a"); customBinder.AddChildBinder("Date", typeof(HtmlPropertyBinderAction), "td:nth-child(5)"); customBinder.AddChildBinder("Time", typeof(HtmlPropertyBinderAction), "td:nth-child(6)"); customBinder.AddChildBinder("Stadium", typeof(HtmlPropertyBinderAction), "td:nth-child(7)"); customBinder.AddChildBinder("Organization", typeof(HtmlPropertyBinderAction), "td:nth-child(8) span"); }
public DomAttributeCollection(WebScraperDispatcher dispatcher, string browserID, object comObject) { _dispatcher = dispatcher; _browserID = browserID; _comObject = comObject; }
public TffMatchInfoScraper() { _matchDataDriver = new MatchDataDriver(); _dataSourceDriver = new DataSourceDriver(); _dispatcher = new WebScraperDispatcher(); }
public static void WebFetcherDispatcherTest() { WebScraperDispatcher dispatcher = new WebScraperDispatcher(); var b = dispatcher.AddBrowser(); dispatcher.NavigateAsync(b.ID, "http://www.tff.org/Default.aspx?pageID=29&macId=106354", (browser) => { IDomElement elem = new DomDocument(dispatcher, b.ID); //elem = elem.Find(".GriBorder.beyazBG"); //elem = elem.Find(".MacDetaySayi"); //elem = elem.Find("#ctl00_MPane_m_29_194_ctnr_m_29_194_MacBilgiDisplay1_dtMacBilgisi_lblTakim1Skor"); Console.WriteLine(elem.Find("#ctl00_MPane_m_29_194_ctnr_m_29_194_MacBilgiDisplay1_dtMacBilgisi_lnkTakim1").Html + " : " + elem.Find("#ctl00_MPane_m_29_194_ctnr_m_29_194_MacBilgiDisplay1_dtMacBilgisi_lblTakim1Skor").Html + " - " + elem.Find("#ctl00_MPane_m_29_194_ctnr_m_29_194_MacBilgiDisplay1_dtMacBilgisi_lnkTakim2").Html + " : " + elem.Find("#ctl00_MPane_m_29_194_ctnr_m_29_194_MacBilgiDisplay1_dtMacBilgisi_Label12").Html); }); }
public static void TffScrapper() { WebScraperDispatcher dispatcher = new WebScraperDispatcher(); TffSourceScraper tff = new TffSourceScraper(dispatcher); tff.Run(); }
public DomDocument(WebScraperDispatcher dispatcher, string browserID) : base(dispatcher, browserID, null) { _comObject = dispatcher.EvalScript(browserID, "$$WB$$Document"); }
public WebScraperBrowser(WebScraperDispatcher appDispatcher, Dispatcher threadDispatcher) : base() { this._id = Guid.NewGuid().ToString(); _appDispatcher = appDispatcher; _threadDispatcher = threadDispatcher; this._browser = new WebBrowser(); this._browser.LoadCompleted += Browser_LoadCompleted; this._browser.Navigated += Browser_Navigated; this._browser.ObjectForScripting = new ExternalScript(this); this.Content = new StackPanel(); (this.Content as StackPanel).Children.Add(this._browser); this.Show(); }