不能使用JSON.net从stats.nba下载JSON文件

时间:2017-09-02 23:49:01

标签: c# json xml json.net webclient

我想下载这个json文件http://stats.nba.com/stats/leaguestandingsv3?LeagueID=00&Season=2015-16&SeasonType=Regular+Season,但是当我运行我的程序时没有任何事情发生,我得到一个超时异常。我必须最终将它放在数据表中,所以不要介意那部分,我只是想让它先工作。我正在使用json.net btw。

// 0. If using a module system (e.g. via vue-cli), import Vue and VueRouter and then call `Vue.use(VueRouter)`.

// 1. Define route components.
// These can be imported from other files
const Foo = { template: '<div>foo</div>' }
const Bar = { template: '<div>bar</div>' }

// 2. Define some routes
// Each route should map to a component. The "component" can
// either be an actual component constructor created via
// `Vue.extend()`, or just a component options object.
// We'll talk about nested routes later.
const routes = [
  { path: '/foo', component: Foo },
  { path: '/bar', component: Bar }
]

// 3. Create the router instance and pass the `routes` option
// You can pass in additional options here, but let's
// keep it simple for now.
const router = new VueRouter({
  routes // short for `routes: routes`
})

// 4. Create and mount the root instance.
// Make sure to inject the router with the router option to make the
// whole app router-aware.
const app = new Vue({
  router: router
}).$mount('#app')

1 个答案:

答案 0 :(得分:4)

将以下标题添加到请求中对我有用:

    using (WebClient wc1 = new WebClient())
    {
        var link = "http://stats.nba.com/stats/leaguestandingsv3?LeagueID=00&Season=2015-16&SeasonType=Regular+Season";
        wc1.Headers.Add("accept-encoding", "Accepflate, sdch");
        wc1.Headers.Add("Accept-Language","en");
        wc1.Headers.Add("origin","http://stats.nba.com");
        wc1.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36");
        var json1 = wc1.DownloadString(link);
    }

在此处查看结果:https://dotnetfiddle.net/6Ugrm5