public ICollection<Uri> Search(string searchFor) { ICollection<Uri> is2 = null; string str; int num; bool flag; MemoryStream os = new MemoryStream(); FormUtility utility = new FormUtility(os, null); if ((((uint) flag) + ((uint) num)) <= uint.MaxValue) { utility.Add("appid", "YahooDemo"); goto Label_00E2; } Label_0093: if (((uint) flag) <= uint.MaxValue) { os.Dispose(); Uri uri = new Uri("http://search.yahooapis.com/WebSearchService/V1/webSearch?" + str); num = 0; flag = false; while (!flag) { try { is2 = this.x7cdeaeac68d869b5(uri); flag = true; } catch (IOException) { do { if (num == 5) { throw; } Thread.Sleep(0x1388); } while ((((uint) flag) - ((uint) num)) > uint.MaxValue); } num++; } return is2; } Label_00E2: utility.Add("results", "100"); utility.Add("query", searchFor); utility.Complete(); str = new ASCIIEncoding().GetString(os.GetBuffer()); goto Label_0093; }
/// <summary> /// Perform a Yahoo search. /// </summary> /// <param name="searchFor">What are we searching for.</param> /// <returns>The URLs that contain the specified item.</returns> public ICollection<Uri> Search(String searchFor) { ICollection<Uri> result = null; // build the Uri var mstream = new MemoryStream(); var form = new FormUtility(mstream, null); form.Add("appid", "YahooDemo"); form.Add("results", "100"); form.Add("query", searchFor); form.Complete(); var enc = new ASCIIEncoding(); String str = enc.GetString(mstream.GetBuffer()); mstream.Dispose(); var uri = new Uri( "http://search.yahooapis.com/WebSearchService/V1/webSearch?" + str); int tries = 0; bool done = false; while (!done) { try { result = DoSearch(uri); done = true; } catch (IOException e) { if (tries == 5) { throw; } Thread.Sleep(5000); } tries++; } return result; }
/// <summary> /// This method builds a URL to load data from Yahoo Finance for a neural /// network to train with. /// </summary> /// <param name="ticker">The ticker symbol to access.</param> /// <param name="from">The beginning date.</param> /// <param name="to">The ending date.</param> /// <returns>The URL to read from</returns> private static Uri BuildURL(String ticker, DateTime from, DateTime to) { // construct the URL var mstream = new MemoryStream(); var form = new FormUtility(mstream, null); form.Add("s", ticker); form.Add("a", "" + (from.Month - 1)); form.Add("b", "" + from.Day); form.Add("c", "" + from.Year); form.Add("d", "" + (to.Month - 1)); form.Add("e", "" + to.Day); form.Add("f", "" + to.Year); form.Add("g", "d"); form.Add("ignore", ".csv"); mstream.Close(); byte[] b = mstream.GetBuffer(); String str = "http://ichart.finance.yahoo.com/table.csv?" + StringUtil.FromBytes(b); return new Uri(str); }
/// <summary> /// Navigate based on a form. Complete and post the form. /// </summary> /// <param name="form">The form to be posted.</param> /// <param name="submit">The submit button on the form to simulate clicking.</param> public void Navigate(Form form, Input submit) { try { #if logging if (logger.IsInfoEnabled) { logger.Info("Posting a form"); } #endif Stream istream; Stream ostream; Uri targetURL; WebRequest http = null; if (form.Method == Form.FormMethod.Get) { ostream = new MemoryStream(); } else { http = WebRequest.Create(form.Action.Url); http.Timeout = 30000; http.ContentType = "application/x-www-form-urlencoded"; http.Method = "POST"; ostream = http.GetRequestStream(); } // add the parameters if present var formData = new FormUtility(ostream, null); foreach (DocumentRange dr in form.Elements) { if (dr is FormElement) { var element = (FormElement) dr; if ((element == submit) || element.AutoSend) { String name = element.Name; String value = element.Value; if (name != null) { if (value == null) { value = ""; } formData.Add(name, value); } } } } // now execute the command if (form.Method == Form.FormMethod.Get) { String action = form.Action.Url.ToString(); ostream.Close(); action += "?"; action += ostream.ToString(); targetURL = new Uri(action); http = WebRequest.Create(targetURL); var response = (HttpWebResponse) http.GetResponse(); istream = response.GetResponseStream(); } else { targetURL = form.Action.Url; ostream.Close(); var response = (HttpWebResponse) http.GetResponse(); istream = response.GetResponseStream(); } Navigate(targetURL, istream); istream.Close(); } catch (IOException e) { throw new BrowseError(e); } }
private static Uri x38c212309d8d5dd3(string x96e4701dec47675e, DateTime x7f8a886f51b477eb, DateTime x3ed4f4f0195b98d7) { FormUtility utility; byte[] buffer; MemoryStream os = new MemoryStream(); goto Label_012A; Label_000B: buffer = os.GetBuffer(); string uriString = "http://ichart.finance.yahoo.com/table.csv?" + StringUtil.FromBytes(buffer); if (3 != 0) { return new Uri(uriString); } Label_012A: utility = new FormUtility(os, null); utility.Add("s", x96e4701dec47675e); utility.Add("a", (x7f8a886f51b477eb.Month - 1)); utility.Add("b", x7f8a886f51b477eb.Day); if (2 == 0) { goto Label_000B; } utility.Add("c", x7f8a886f51b477eb.Year); utility.Add("d", (x3ed4f4f0195b98d7.Month - 1)); Label_010C: utility.Add("e", x3ed4f4f0195b98d7.Day); utility.Add("f", x3ed4f4f0195b98d7.Year); utility.Add("g", "d"); utility.Add("ignore", ".csv"); os.Close(); if (8 != 0) { if (0 != 0) { goto Label_010C; } goto Label_000B; } goto Label_012A; }
/// <summary> /// This method builds a URL to load data from Oanda for a neural /// network to train with. /// </summary> /// <param name="ticker">The currency pair to access.</param> /// <param name="from">The begin date.</param> /// <param name="to">the ending date.</param> /// <returns>The URL to read from.</returns> private Uri buildURL( TickerSymbol ticker, DateTime from, DateTime to ) { // construct the url MemoryStream mstream = new MemoryStream(); FormUtility form = new FormUtility(mstream, null); String[] currencies = ticker.Symbol.Split('/'); // each param gets added individually as query parameter form.Add("exch", currencies[0].ToUpper()); form.Add("expr2", currencies[1].ToUpper()); form.Add("date1", from.ToString("MM-dd-yyyy")); form.Add("date2", to.ToString("MM-dd-yyyy")); form.Add("date_fmt", "us"); form.Add("lang","en"); form.Add("margin_fixed", "0"); form.Add("SUBMIT", "Get+Table"); form.Add("format", "CSV"); form.Add("redirected", "1"); mstream.Close(); byte[] b = mstream.GetBuffer(); String str = "http://www.oanda.com/convert/fxhistory?" + StringUtil.FromBytes(b); return new Uri(str); }
private Uri BuildURL( TickerSymbol ticker, DateTime from, DateTime to ) { int selectedPair = -1; Uri url; #region Select Currency Pair switch (ticker.Symbol) { case "AUDJPY": selectedPair = DukascopyData["AUDJPY"]; break; case "AUDUSD": selectedPair = DukascopyData["AUDUSD"]; break; case "CADJPY": selectedPair = DukascopyData["CADJPY"]; break; case "CHFJPY": selectedPair = DukascopyData["CHFJPY"]; break; case "EURCHF": selectedPair = DukascopyData["EURCHF"]; break; case "EURGBP": selectedPair = DukascopyData["EURGBP"]; break; case "EURJPY": selectedPair = DukascopyData["EURJPY"]; break; case "EURUSD": selectedPair = DukascopyData["EURUSD"]; break; case "GBPEUR": selectedPair = DukascopyData["GBPEUR"]; break; case "GBPJPY": selectedPair = DukascopyData["GBPJPY"]; break; case "GBPUSD": selectedPair = DukascopyData["GBPUSD"]; break; case "JPYCHF": selectedPair = DukascopyData["JPYCHF"]; break; case "NZDUSD": selectedPair = DukascopyData["NZDUSD"]; break; case "XPDUSD": selectedPair = DukascopyData["XPDUSD"]; break; case "XPTUSD": selectedPair = DukascopyData["XPTUSD"]; break; case "USDCAD": selectedPair = DukascopyData["USDCAD"]; break; case "USDCHF": selectedPair = DukascopyData["USDCHF"]; break; case "USDJPY": selectedPair = DukascopyData["USDJPY"]; break; case "XAGUSD": selectedPair = DukascopyData["XAGUSD"]; break; case "XAUUSD": selectedPair = DukascopyData["XAUUSD"]; break; default: break; } #endregion Select Currency Pair if (selectedPair != -1) { /* * fromD = mm.dd.yyyy * np = 259, 1000, 1500, 2000 * interval = 60, 600, 3600, 1D, 7D, 1MO * DF = m/d/Y, m.d.Y, d.m.Y, m-d-Y, d-m-Y * endSym = win, unix * split = tz, coma, tab (; , tab) * */ // construck URL MemoryStream mstream = new MemoryStream(); FormUtility form = new FormUtility(mstream, null); form.Add("Stock", selectedPair.ToString()); form.Add("fromD", from.ToString("mm.DD.yyyy")); form.Add("np", "2000"); form.Add("interval", "1D"); form.Add("DF", "m-d-Y"); // date format form.Add("endSym", "win"); form.Add("split", "coma"); mstream.Close(); byte[] b = mstream.GetBuffer(); String str = "http://www.dukascopy.com/freeApplets/exp/exp.php?" + StringUtil.FromBytes(b); url = new Uri(str); } return url; }
private static Uri x38c212309d8d5dd3(TickerSymbol x96e4701dec47675e, DateTime x7f8a886f51b477eb, DateTime x3ed4f4f0195b98d7) { byte[] buffer; MemoryStream os = new MemoryStream(); FormUtility utility = new FormUtility(os, null); utility.Add("s", x96e4701dec47675e.Symbol.ToUpper()); if (0 == 0) { utility.Add("a", (x7f8a886f51b477eb.Month - 1)); utility.Add("b", x7f8a886f51b477eb.Day); if (4 == 0) { goto Label_0018; } utility.Add("c", x7f8a886f51b477eb.Year); utility.Add("d", (x3ed4f4f0195b98d7.Month - 1)); utility.Add("e", x3ed4f4f0195b98d7.Day); utility.Add("f", x3ed4f4f0195b98d7.Year); utility.Add("g", "d"); goto Label_0061; } Label_000B: if (0x7fffffff == 0) { goto Label_0061; } os.Close(); Label_0018: buffer = os.GetBuffer(); return new Uri("http://ichart.finance.yahoo.com/table.csv?" + StringUtil.FromBytes(buffer)); Label_0061: utility.Add("ignore", ".csv"); goto Label_000B; }
public void Navigate(Form form, Input submit) { try { Stream requestStream; Uri url; FormUtility utility; string str3; HttpWebResponse response; WebRequest request = null; goto Label_01D3; Label_0007: requestStream.Close(); Stream responseStream = ((HttpWebResponse) request.GetResponse()).GetResponseStream(); Label_0022: this.Navigate(url, responseStream); Label_002A: responseStream.Close(); if (0 == 0) { return; } if (0 == 0) { goto Label_0057; } Label_0036: responseStream = response.GetResponseStream(); goto Label_0022; Label_0040: if (form.Method == Form.FormMethod.Get) { goto Label_0081; } url = form.Action.Url; goto Label_0007; Label_0057: response = (HttpWebResponse) WebRequest.Create(url).GetResponse(); goto Label_0036; Label_0074: url = new Uri(str3); goto Label_0057; Label_0081: str3 = form.Action.Url.ToString(); requestStream.Close(); str3 = str3 + "?" + requestStream.ToString(); goto Label_0074; Label_00BB: if (0x7fffffff == 0) { goto Label_0074; } goto Label_0040; Label_00C7: request.Method = "POST"; requestStream = request.GetRequestStream(); Label_00D9: utility = new FormUtility(requestStream, null); if (0 != 0) { goto Label_002A; } using (IEnumerator<DocumentRange> enumerator = form.Elements.GetEnumerator()) { DocumentRange range; FormElement element; string str; string str2; goto Label_0109; Label_00F7: if (element.AutoSend) { goto Label_0163; } goto Label_0109; Label_0105: if (str != null) { goto Label_013B; } Label_0109: if (enumerator.MoveNext()) { goto Label_016E; } goto Label_0141; Label_0117: str2 = ""; if (0 != 0) { goto Label_0163; } Label_0121: utility.Add(str, str2); goto Label_0109; Label_012E: if (range is FormElement) { goto Label_017D; } goto Label_0109; Label_013B: if (str2 != null) { goto Label_0121; } goto Label_0117; Label_0141: if (0 == 0) { goto Label_0040; } goto Label_016E; Label_0146: str2 = element.Value; if (0 == 0) { goto Label_0105; } if (-2147483648 != 0) { goto Label_016E; } Label_0159: if (element != submit) { goto Label_00F7; } Label_0163: str = element.Name; goto Label_0146; Label_016E: range = enumerator.Current; if (0 != 0) { goto Label_0109; } if (0 == 0) { goto Label_012E; } Label_017D: element = (FormElement) range; goto Label_0159; } goto Label_00BB; Label_019F: requestStream = new MemoryStream(); goto Label_00D9; Label_01AA: request = WebRequest.Create(form.Action.Url); request.Timeout = 0x7530; request.ContentType = "application/x-www-form-urlencoded"; goto Label_00C7; Label_01D3: if (form.Method != Form.FormMethod.Get) { goto Label_01AA; } goto Label_019F; } catch (IOException exception) { throw new BrowseError(exception); } }