c# - 打开 URL 抛出 String 未被识别为有效的 DateTime
问题描述
使用 AngleSharp v 0.9.9.0 这个:
var siteUrl = "https://richmond.csod.com/ats/careersite/search.aspx?site=1&c=richmond";
var configuration = Configuration.Default.WithDefaultLoader().WithCookies();
var currentContext = BrowsingContext.New(configuration);
var originalDoc = currentContext.OpenAsync(siteUrl).Result;
Console.WriteLine(originalDoc.DocumentElement.OuterHtml);
工作正常。但是如果我升级到 v 0.9.9.2,它会抛出这个:
Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.FormatException: String was not recognized as a valid DateTime.
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
at AngleSharp.Services.Default.MemoryCookieProvider.Sanatize(String cookie)
at AngleSharp.Services.Default.MemoryCookieProvider.SetCookie(String origin, String value)
at AngleSharp.Dom.Document.set_Cookie(String value)
at AngleSharp.Dom.Document.Setup(CreateDocumentOptions options)
at AngleSharp.Dom.Html.HtmlDocument.<LoadAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at AngleSharp.BrowsingContextExtensions.<OpenAsync>d__2.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at System.Threading.Tasks.Task`1.get_Result()
at AngleSharpTest.Program.Main(String[] args) in C:\Users\matt.burland\source\repos\AngleSharpTest\AngleSharpTest\Program.cs:line 21
它似乎来自 AngleSharp 内部,并且发生在几个不同的、完全不相关的 url 上。FWIW,我的文化设置是en-US
,并且我尝试设置为不变的文化,但这似乎也无济于事。
有没有其他人看到这个问题?有解决办法吗?
解决方案
推荐阅读
- php - 从 Twinfield API 获取未经授权的客户端
- javascript - 我制作了一个虚拟键盘,当我从键盘(数字)检查显示值时,它是未定义的......我如何获得一个数字作为值?
- image - 在离子角度中使用来自 ms-appdata 源路径的图像
- pandas - 阅读有趣的分隔 txt 文件
- spring-boot - 从 Spring Boot 中内部 api 的响应创建 bean
- android - 有没有办法使用断言检查 jetpack compose 中嵌套组件的颜色?
- r - 从变量转移到数据框过滤
- gcloud - Google Cloud Composer 在欧洲西部的可用性4
- vaadin - Vaadin:为什么例如 HorizontalLayout 有一个 Shadow DOM
- latex - 在 PDF 的末尾放一个封底(latex,Rmarkdown)