private void callApibjhb()
{
//输出执行的开始时间
Console.WriteLine(string.Format("Bind {0}", DateTime.Now));
Thread T = new Thread(() =>
{ //表示不停刷新,如果不需要可以删除
while (true) { string strURL = "";
try
{
System.GC.Collect();
string strURL =“你请求的网址”;
System.Net.HttpWebRequest request;
// 创建一个HTTP请求
request = (System.Net.HttpWebRequest)WebRequest.Create(strURL);
request.Method = "GET";
request.Timeout = ;
request.ContentType = "application/json;charset=UTF-8";
request.ServicePoint.Expect100Continue = false;
request.KeepAlive = false;
System.Net.ServicePointManager.DefaultConnectionLimit = ;
System.Net.HttpWebResponse response;
response = (System.Net.HttpWebResponse)request.GetResponse();
Stream myResponseStream = response.GetResponseStream();
StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
string retString = myStreamReader.ReadToEnd();
Console.WriteLine("ret string === {0}+ {1}", retString, strURL);
//创建RepParambj28hb类,字段格式是:根据“请求网站返回的Json字符串”,到网上搜“在线Json格式化”去解析
RepParambj28hb rep = JsonConvert.DeserializeObject<RepParambj28hb>(retString);
for (int i = ; i < rep.result.lotterys.Length; i++)
{
//根据自己的需求,得到值
string jh = rep.result.lotterys[i].opencode.Replace(",", "");
dt.Rows[dt.Rows.Count - ]["cl1"] = rep.result.lotterys[i].expect;
}
myStreamReader.Close();
myResponseStream.Close(); }
catch (Exception webEx)
{
}
}
}); T.Start();
Console.WriteLine(string.Format("Bind end {0}", DateTime.Now));
}

winform c# 请求网站,返回Json字符串的更多相关文章

  1. 根据传入url请求,返回json字符串

    /** * 根据传入url请求,返回json字符串 * @param url * @return * @throws UnsupportedEncodingException */ public st ...

  2. HttpClient 模拟发送Post和Get请求 并用fastjson对返回json字符串数据解析,和HttpClient一些参数方法的deprecated(弃用)的综合总结

    最近在做一个接口调用的时候用到Apache的httpclient时候,发现引入最新版本4.5,DefaultHttpClient等老版本常用的类已经过时了,不推荐使用了:去官网看了一下在4.3之后就抛 ...

  3. ajax请求返回json字符串/json对象 处理

    1. 返回json字符串如何处理 $.ajax({ url:xxx, success:function(date){ }, error:function(){ } }); 通过最原始的返回: Prin ...

  4. Jsoup请求http或https返回json字符串工具类

    Jsoup请求http或https返回json字符串工具类 所需要的jar包如下: jsoup-1.8.1.jar 依赖jar包如下: httpclient-4.5.4.jar; httpclient ...

  5. Query通过Ajax向PHP服务端发送请求并返回JSON数据

    Query通过Ajax向PHP服务端发送请求并返回JSON数据 服务端PHP读取MYSQL数据,并转换成JSON数据,传递给前端Javascript,并操作JSON数据.本文将通过实例演示了jQuer ...

  6. springmvc返回json字符串中文乱码问题

    问题: 后台代码如下: @RequestMapping("menuTreeAjax") @ResponseBody /** * 根据parentMenuId获取菜单的树结构 * @ ...

  7. shiro 返回json字符串 + 自定义filter

    前言: 在前后端分离的项目中, 在使用shiro的时候, 我们绝大部分时候, 并不想让浏览器跳转到那个页面去, 而是告诉前端, 你没有登录, 或者没有访问权限. 那这时候, 我们就需要返回json字符 ...

  8. 160506、Spring mvc新手入门(11)-返回json 字符串的其他方式

    Spring MVC返回 json字符串的方式有很多种方法,这里介绍最简单,也是最常使用的两种方式 一.使用  PrintWriter printWriter  直接输出字符串到返回结果中    不需 ...

  9. Spring Security 前后端分离登录,非法请求直接返回 JSON

    hello 各位小伙伴,国庆节终于过完啦,松哥也回来啦,今天开始咱们继续发干货! 关于 Spring Security,松哥之前发过多篇文章和大家聊聊这个安全框架的使用: 手把手带你入门 Spring ...

随机推荐

  1. C#实现获取当前文件路径的上级路径

    界面: 声明: textBox1.Text为指定文件路径:string path = @"F:\ABB-pragram\ABB工作站\ABB Station\Systems\Situatio ...

  2. 小程序checkbox调整大小

    .cb{ transform: scale(0.6,0.6); } <view> <label class="lab" for="box1"& ...

  3. OpenGL ES: (2) OpenGL ES 与 EGL、GLSL的关系

    OpenGL ES 是负责 GPU 工作的,目的是通过 GPU 计算,得到一张图片,这张图片在内存中其实就是一块 buffer,存储有每个点的颜色信息等.而这张图片最终是要显示到屏幕上,所以还需要具体 ...

  4. Swift_IOS之提示框UIAlertController

    import UIKit class ViewController: UIViewController ,UIActionSheetDelegate{ @IBAction func btn1(_ se ...

  5. sed替换 - 含反斜杠(/)和Shell变量

    sed替换 - 含反斜杠(/)和Shell变量 摘自: https://blog.csdn.net/zhenyongyuan123/article/details/6616263 2011年07月19 ...

  6. Qt pri文件

    pri文件就是一个简单的文件夹包含或者动态库调用路径等说明,在pro文件里include了pri文件,相当于把pri文件的内容直接复制到pro文件中

  7. ABAP Memory ID

    转自:https://blog.csdn.net/lyq123333321/article/details/52659114 (一)          Difference Between SAP a ...

  8. LeetCode_172. Factorial Trailing Zeroes

    172. Factorial Trailing Zeroes Easy Given an integer n, return the number of trailing zeroes in n!. ...

  9. 未能加载文件或程序集“System.Web.Extensions, Version=1.0.61025.0, Culture=neutral

    近日将电脑重装了一下,刚刚装上vs2005后打开以前的一个项目,居然出现了下面的错误: 未能加载文件或程序集“System.Web.Extensions.Design, Version=1.0.610 ...

  10. cursor -- 定义鼠标样式

    cursor -- 定义鼠标样式 取值: [ [<uri> ,]* [ auto | crosshair | default | pointer | move | e-resize | n ...