c# - 使用 AngleSharp 向 Microsoft 进行身份验证
问题描述
我正在尝试使用 AngleSharp 对 login.microsoftonline.com 进行身份验证,以便我可以使用它们作为 SSO 提供程序从站点收集数据。
到目前为止我得到的代码: -
var config = Configuration.Default
.WithJs()
.WithCss()
.WithDefaultLoader()
.WithDefaultCookies();
IBrowsingContext browsingContext = BrowsingContext.New(config);
browsingContext.OpenAsync(@"http://login.microsoftonline.com/").Wait();
(browsingContext.Active.QuerySelector("input[name = 'loginfmt']") as IHtmlInputElement).Value = @"username";
(browsingContext.Active.QuerySelector("form") as IHtmlFormElement).SubmitAsync().Wait();
(browsingContext.Active.QuerySelector("input[name = 'passwd']") as IHtmlInputElement).Value = @"password";
(browsingContext.Active.QuerySelector("form") as IHtmlFormElement).SubmitAsync().Wait();
// Further code then using the cookie(s) once authenticated...
本质上,'input[name = 'loginfmt']' 使用此代码解析为无,尽管在浏览器中工作正常......在检查“活动”文档(及其子文档)后,它似乎只是充满了JavaScript并且在任何地方都看不到表单..?
解决方案
推荐阅读
- r - 用于 Phi 系数的 R 循环
- linux - linux内核如何为睡眠进程计时?
- node.js - 在 Sequelize.js 的聚合函数中使用 case-when
- r - 仅用于 4 x 4 图的底部面板的 X 轴标题
- c++ - unique_ptr 中模板和继承的重载解决方案
- angular - 从嵌套的 rxjs 订阅中填充 2 个不同列表的角树结构
- java - 如何修复有关已弃用语法的 Apache Camel WARN
- erlang - 在 Tsung 中生成带有动态变量的自定义日志
- json - 在 Azure 逻辑应用中解析/迭代时如何指定 JSON 节点属性值?
- r - grepl 用于允许的任何字符串