小编Sea*_*tel的帖子

如何在C#HttpClient中将调用循环到分页URL以从JSON结果下载所有页面

我的第一个问题,所以请善待...... :)

我正在使用C# HttpClient来调用Jobs API Endpoint.

这是端点:Jobs API Endpoint(不需要密钥,你可以点击它)

这给了我这样的JSON.

{
  "count": 1117,
  "firstDocument": 1,
  "lastDocument": 50,
  "nextUrl": "\/api\/rest\/jobsearch\/v1\/simple.json?areacode=&country=&state=&skill=ruby&city=&text=&ip=&diceid=&page=2",
  "resultItemList": [
    {
      "detailUrl": "http:\/\/www.dice.com\/job\/result\/90887031\/918715?src=19",
      "jobTitle": "Sr Security Engineer",
      "company": "Accelon Inc",
      "location": "San Francisco, CA",
      "date": "2017-03-30"
    },
    {
      "detailUrl": "http:\/\/www.dice.com\/job\/result\/cybercod\/BB7-13647094?src=19",
      "jobTitle": "Platform Engineer - Ruby on Rails, AWS",
      "company": "CyberCoders",
      "location": "New York, NY",
      "date": "2017-04-16"
    }
 ]
}
Run Code Online (Sandbox Code Playgroud)

我已经粘贴了一个完整的JSON代码段,因此您可以在答案中使用它.完整的结果真的很长.

这是C#类.

using Newtonsoft.Json;
using System.Collections.Generic;

namespace MyNameSpace
{
    public class DiceApiJobWrapper
    {
        public int count { …
Run Code Online (Sandbox Code Playgroud)

c# asynchronous httpclient json.net task-parallel-library

1
推荐指数
1
解决办法
4338
查看次数