protected async Task <string> GetHtml(string url) { try { string html = await HttpBaseService.SendGetRequest(url); //byte[] bytes = Encoding.UTF8.GetBytes(html); //html = Encoding.GetEncoding("GBK").GetString(bytes); Printlog("请求Html数据成功 URL:" + url); return(html); } catch { Printlog("请求Html数据失败 URL:" + url); return(null); } }
protected async Task <WriteableBitmap> GetImage(string url) { try { IBuffer buffer = await HttpBaseService.SendGetRequestAsBytes(url); if (buffer != null) { BitmapImage bi = new BitmapImage(); WriteableBitmap wb = null; Stream stream2Write; using (InMemoryRandomAccessStream stream = new InMemoryRandomAccessStream()) { stream2Write = stream.AsStreamForWrite(); await stream2Write.WriteAsync(buffer.ToArray(), 0, (int)buffer.Length); await stream2Write.FlushAsync(); stream.Seek(0); await bi.SetSourceAsync(stream); wb = new WriteableBitmap(bi.PixelWidth, bi.PixelHeight); stream.Seek(0); await wb.SetSourceAsync(stream); return(wb); } } else { return(null); } } catch { return(null); } }
protected async Task <JsonObject> GetJson(string url) { try { string json = await HttpBaseService.SendGetRequest(url); if (json != null) { Printlog("请求Json数据成功 URL:" + url); return(JsonObject.Parse(json)); } else { Printlog("请求Json数据失败 URL:" + url); return(null); } } catch { Printlog("请求Json数据失败 URL:" + url); return(null); } }