使用C#和Flurl.Http库的下载器程序

根据您的要求,我为您编写了一个使用C#和Flurl.Http库的下载器程序,用于下载凤凰网的图片。以下是一个简单的示例代码:

代码语言:javascript
复制
```csharp
using System;
using Flurl.Http;

namespace DownloadImage
{
class Program
{
static void Main(string[] args)
{
string url = "https://www.ifeng.com/";
string filePath = "C:\Download\ifeng.com.png";

        DownloadImage(url, filePath);
    }

    static void DownloadImage(string url, string filePath)
    {
        using (var client = new FlurlClient())
        {
            var response = client.GetAsync(url).ReceiveJson();

            if (response["error"] == null)
            {
                var imageUrl = response["data"]["imageUrl"].ToString();
                DownloadImageToFile(imageUrl, filePath);
            }
            else
            {
                Console.WriteLine("下载失败,错误信息:");
                Console.WriteLine(response["message"]);
            }
        }
    }

    static void DownloadImageToFile(string imageUrl, string filePath)
    {
        using (var client = new FlurlClient())
        {
            var response = client.GetAsync(imageUrl).ReceiveString();
            var imageBytes = Convert.FromBase64String(response);
            using (var fileStream = System.IO.File.Create(filePath))
            {
                fileStream.Write(imageBytes, 0, imageBytes.Length);
            }
        }
    }
}

}