修复抓取资讯报错bug问题
parent
43c0572015
commit
a77c80d023
|
|
@ -52,8 +52,7 @@ namespace New_College.Tasks
|
||||||
ProvinceCode = "370000",
|
ProvinceCode = "370000",
|
||||||
CreateId = 1,
|
CreateId = 1,
|
||||||
CreateTime = c.pubtime,
|
CreateTime = c.pubtime,
|
||||||
|
Detail = c.detail,
|
||||||
// Detail = c.detail,
|
|
||||||
CoverImg = "https://static-data.ycymedu.com/static/newstop.png",
|
CoverImg = "https://static-data.ycymedu.com/static/newstop.png",
|
||||||
OrderSort = 0,
|
OrderSort = 0,
|
||||||
IsDelete = false,
|
IsDelete = false,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using Aliyun.OSS.Model;
|
using Aliyun.OSS.Model;
|
||||||
using HtmlAgilityPack;
|
using HtmlAgilityPack;
|
||||||
|
using New_College.Common.Helper;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
@ -26,18 +27,22 @@ namespace New_College.Tasks
|
||||||
}
|
}
|
||||||
listurls.ForEach(url =>
|
listurls.ForEach(url =>
|
||||||
{
|
{
|
||||||
|
|
||||||
var doc = webClient.Load(url);
|
var doc = webClient.Load(url);
|
||||||
var inntertitle = doc.DocumentNode.SelectSingleNode("//*[@id=\"form1\"]/div[6]/div[2]/h3").InnerText;
|
var inntertitle = doc.DocumentNode.SelectSingleNode("//*[@id=\"form1\"]/div[6]/div[2]/h3").InnerText;
|
||||||
var author = doc.DocumentNode.SelectSingleNode("//*[@id=\"form1\"]/div[6]/div[2]/em").InnerText.Split("作者:")[1].Split(" ")[0];
|
var author = doc.DocumentNode.SelectSingleNode("//*[@id=\"form1\"]/div[6]/div[2]/em").InnerText.Split("作者:")[1].Split(" ")[0];
|
||||||
var createtime = doc.DocumentNode.SelectSingleNode("//*[@id=\"form1\"]/div[6]/div[2]/em").InnerText.Split("发布时间:")[1];
|
var createtime = doc.DocumentNode.SelectSingleNode("//*[@id=\"form1\"]/div[6]/div[2]/em").InnerText.Split("发布时间:")[1];
|
||||||
var innerhtml = doc.DocumentNode.SelectSingleNode("//*[@id=\"form1\"]/div[6]/div[2]/div").InnerHtml;
|
var innerhtml = doc.DocumentNode.SelectSingleNode("//*[@id=\"form1\"]/div[6]/div[2]/div").InnerHtml;
|
||||||
list.Add(new NewsModels()
|
if (!HtmlHelper.ReplaceHtmlTag(innerhtml).Contains("浏览器"))
|
||||||
{
|
{
|
||||||
title = inntertitle,
|
list.Add(new NewsModels()
|
||||||
author = author,
|
{
|
||||||
pubtime = Convert.ToDateTime(createtime),
|
title = inntertitle,
|
||||||
detail = innerhtml.Replace("src=\"", "src=\"https://www.sdzk.cn").Replace("href=\"", "href=\"https://www.sdzk.cn")
|
author = author,
|
||||||
});
|
pubtime = Convert.ToDateTime(createtime),
|
||||||
|
detail = innerhtml.Replace("src=\"", "src=\"https://www.sdzk.cn").Replace("href=\"", "href=\"https://www.sdzk.cn")
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue