///<summary> ///Recursive Method, recall this method when timeout or other errors happend ///Call PDFAnalysis method to download PDF from from http://www.hkexnews.hk/listedco/listconews/advancedsearch/search_active_main.asp ///and extract data from PDF by specific stock code ///</summary> ///<param name="index">ricList index</param> ///<returns> void </returns> private void DataCaptureFromPDF(int index) { ISelenium pdfSearch1 = new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.hkexnews.hk"); int start_position = index; pdfSearch1.Start(); try { pdfSearch1.Open("/listedco/listconews/advancedsearch/search_active_main.asp"); pdfSearch1.WaitForPageToLoad("60000"); for (; start_position < ricList.Count; start_position++) { pdfSearch1.Type("txt_stock_code", ricList[start_position].ricCodeStr); pdfSearch1.Click("//table[@id='Table1']/tbody/tr[3]/td/table[2]/tbody/tr/td/table/tbody/tr[14]/td[3]/label/a[1]/img"); pdfSearch1.WaitForPageToLoad("30000"); String pdfUrl = pdfSearch1.GetAttribute("//table[@id='Table4']/tbody/tr[8]/td/table/tbody/tr[3]/td[4]/table/tbody/tr/td/a@href"); pdfList.Add(coreObj.PDFAnalysis(pdfUrl, ricList[start_position].ricCodeStr)); pdfSearch1.Click("//table[@id='Table5']/tbody/tr/td/table/tbody/tr/td[1]/a/img"); pdfSearch1.WaitForPageToLoad("30000"); } pdfSearch1.Close(); pdfSearch1.Stop(); } catch (Exception ex) { String errLog = ex.ToString(); coreObj.WriteLogFile(errLog); coreObj.WriteLogFile(ricList[start_position].ricCodeStr); coreObj.WriteLogFile("start_position=" + start_position); pdfSearch1.Close(); pdfSearch1.Stop(); DataCaptureFromPDF(start_position); } }