From 5e75bdf2fd236a6b562080fe2fca592c19d190ef Mon Sep 17 00:00:00 2001 From: Lewis Zou Date: Wed, 22 Apr 2020 18:58:26 +0800 Subject: [PATCH] fix post body is null & portal issue --- package.props | 4 ++-- src/DotnetSpider.Portal/Controllers/API/SpiderController.cs | 5 +++++ src/DotnetSpider.Sample/samples/EntitySpider.cs | 1 + src/DotnetSpider/Agent/HttpClientDownloader.cs | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/package.props b/package.props index 68a4d3e7..4998542c 100644 --- a/package.props +++ b/package.props @@ -4,8 +4,8 @@ true true LICENSE.txt - 5.0.0-beta3 - 5.0.0.1 + 5.0.0-beta4 + 5.0.0.4 zlzforever@163.com; Copyright 2018 Lewis Zou DotnetSpider, a .NET Standard web crawling library. It is lightweight, efficient and fast high-level web crawling & scraping framework diff --git a/src/DotnetSpider.Portal/Controllers/API/SpiderController.cs b/src/DotnetSpider.Portal/Controllers/API/SpiderController.cs index 802d8550..99b6d639 100644 --- a/src/DotnetSpider.Portal/Controllers/API/SpiderController.cs +++ b/src/DotnetSpider.Portal/Controllers/API/SpiderController.cs @@ -234,6 +234,11 @@ namespace DotnetSpider.Portal.Controllers.API .ToDictionaryAsync(x => x.Id, x => x); foreach (var item in @out.Data) { + if (!dict.ContainsKey(item.Batch)) + { + continue; + } + var statistics = dict[item.Batch]; if (statistics != null) { diff --git a/src/DotnetSpider.Sample/samples/EntitySpider.cs b/src/DotnetSpider.Sample/samples/EntitySpider.cs index f64512ea..40b171e2 100644 --- a/src/DotnetSpider.Sample/samples/EntitySpider.cs +++ b/src/DotnetSpider.Sample/samples/EntitySpider.cs @@ -13,6 +13,7 @@ using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Serilog; +using SwiftMQ.DependencyInjection; namespace DotnetSpider.Sample.samples { diff --git a/src/DotnetSpider/Agent/HttpClientDownloader.cs b/src/DotnetSpider/Agent/HttpClientDownloader.cs index 07550ad9..bde90507 100644 --- a/src/DotnetSpider/Agent/HttpClientDownloader.cs +++ b/src/DotnetSpider/Agent/HttpClientDownloader.cs @@ -122,7 +122,7 @@ namespace DotnetSpider.Agent stringContent.Content, Encoding.GetEncoding(stringContent.EncodingName), stringContent.MediaType); } - else if (content is ByteArrayContent byteArrayContent) + else if (content is ByteArrayContent byteArrayContent && byteArrayContent.Bytes != null) { httpRequestMessage.Content = new System.Net.Http.ByteArrayContent(byteArrayContent.Bytes); }