private void GetFilesUrl() { try { StreamReader SrResult = DataStreamRicCreationWithFileDownload.LoginWebSite(usrName, passWord, cookies); HtmlDocument doc = new HtmlDocument(); doc.Load(SrResult); if (doc == null) { return; } HtmlNode node = doc.DocumentNode.SelectSingleNode("//input[@id='ajaxDynaToken']"); if (node == null) { node = doc.DocumentNode.SelectSingleNode("//input[@name='org.apache.struts.taglib.html.TOKEN']"); } string token = node.Attributes["value"].Value.Trim(); node = doc.DocumentNode.SelectSingleNode("//form[@name='mainForm']"); string actionStr = null; if (node != null) { actionStr = node.Attributes["action"].Value.Trim(); } string StResult = DataStreamRicCreationWithFileDownload.ChangeTab(actionStr, token, "1", cookies); Regex regex = new Regex(@"<!--delta.+-->"); MatchCollection matches = regex.Matches(StResult); token = matches[0].Value; int i = token.IndexOf(";"); token = token.Substring(i + 1, 32); StResult = DataStreamRicCreationWithFileDownload.ExpandDropDownBox(actionStr, token, @"37_1%3DExpand%3D-30", cookies); regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalAfricaIndex_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalAfricaIndex_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalAgribusinessIndex_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalAgribusinessIndex_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalAsiaBranchenindizes_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalAsiaBranchenindizes_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalAlternativeEnergy_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalAlternativeEnergy_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalAsiaIndex_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalAsiaIndex_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalAustriaIndices_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalAustriaIndices_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalBRICIndex_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalBRICIndex_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalChinaIndex_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalChinaIndex_IWB"] = matches[0].Value; //page 2 regex = new Regex(@"<!--delta.+-->"); matches = regex.Matches(StResult); token = matches[0].Value; //goto next page i = token.IndexOf(";"); token = token.Substring(i + 1, 32); StResult = DataStreamRicCreationWithFileDownload.ChangePage(actionStr, token, @"37_1%3DPage%3D1", cookies); regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalChinaBranchenindices_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalChinaBranchenindices_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalChinaUrbIndex_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalChinaUrbIndex_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalCoalIndex_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalCoalIndex_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalEmerging11Index_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalEmerging11Index_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalGCCIndex_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalGCCIndex_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalGoldMinersIndex_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalGoldMinersIndex_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalLatinAmericaIndex_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalLatinAmericaIndex_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalNuclearEnergyIndex_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalNuclearEnergyIndex_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalRussiaPlusIndex_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalRussiaPlusIndex_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalRussiaIndex_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalRussiaIndex_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalSarasinSust_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalSarasinSust_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalShippingIndex_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalShippingIndex_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalSteelIndex_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalSteelIndex_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalVietnamIndex_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalVietnamIndex_IWB"] = matches[0].Value; //page 3 regex = new Regex(@"<!--delta.+-->"); matches = regex.Matches(StResult); token = matches[0].Value; //goto next page i = token.IndexOf(";"); token = token.Substring(i + 1, 32); StResult = DataStreamRicCreationWithFileDownload.ChangePage(actionStr, token, @"37_1%3DPage%3D2", cookies); regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAXglobalWaterIndex_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAXglobalWaterIndex_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DBIXIndia_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DBIXIndia_IWB"] = matches[0].Value; } catch (System.Exception ex) { Logger.Log(string.Format("error when getting files url,exception is {0}", ex.ToString())); } }
private void GetFilesUrl() { try { StreamReader SrResult = DataStreamRicCreationWithFileDownload.LoginWebSite(usrName, passWord, cookies); HtmlDocument doc = new HtmlDocument(); doc.Load(SrResult); if (doc == null) { return; } HtmlNode node = doc.DocumentNode.SelectSingleNode("//input[@id='ajaxDynaToken']"); if (node == null) { node = doc.DocumentNode.SelectSingleNode("//input[@name='org.apache.struts.taglib.html.TOKEN']"); } string token = node.Attributes["value"].Value.Trim(); node = doc.DocumentNode.SelectSingleNode("//form[@name='mainForm']"); string actionStr = null; if (node != null) { actionStr = node.Attributes["action"].Value.Trim(); } string StResult = DataStreamRicCreationWithFileDownload.ChangeTab(actionStr, token, "1", cookies); Regex regex = new Regex(@"<!--delta.+-->"); MatchCollection matches = regex.Matches(StResult); token = matches[0].Value; int i = token.IndexOf(";"); token = token.Substring(i + 1, 32); StResult = DataStreamRicCreationWithFileDownload.ExpandDropDownBox(actionStr, token, @"37_1%3DExpand%3D-10", cookies); regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+CDAX_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["CDAX_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+ClassicAllShare_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["ClassicAllShare_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+DAX_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["DAX_IWB"] = matches[0].Value; //page 2 regex = new Regex(@"<!--delta.+-->"); matches = regex.Matches(StResult); token = matches[0].Value; //goto next page i = token.IndexOf(";"); token = token.Substring(i + 1, 32); StResult = DataStreamRicCreationWithFileDownload.ChangePage(actionStr, token, @"37_1%3DPage%3D1", cookies); regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+EntryStandard_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["EntryStandard_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+GEX_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["GEX_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+HDAX_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["HDAX_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+MDAX_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["MDAX_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+MidcapMarketIndex_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["MidcapMarketIndex_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+PrimeAllShare_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["PrimeAllShare_IWB"] = matches[0].Value; //page 3 regex = new Regex(@"<!--delta.+-->"); matches = regex.Matches(StResult); token = matches[0].Value; //goto next page i = token.IndexOf(";"); token = token.Substring(i + 1, 32); StResult = DataStreamRicCreationWithFileDownload.ChangePage(actionStr, token, @"37_1%3DPage%3D2", cookies); regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+SDAX_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["SDAX_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+TecDAX_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["TecDAX_IWB"] = matches[0].Value; regex = new Regex(@"download\/[0-9A-Z]+\.vong_00[a-z0-9_\/]+TechnologyAllShare_IWB\.[0-9]+\.xls"); matches = regex.Matches(StResult); downloadUrl["TechnologyAllShare_IWB"] = matches[0].Value; } catch (System.Exception ex) { Logger.Log(string.Format("error when getting files url,exception is {0}", ex.ToString())); } }