如何在Powershell Core中解析html [英] How to parse html in Powershell Core

查看:357
本文介绍了如何在Powershell Core中解析html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,Powershell Core中的Invoke-WebRequest-UseBasicParsing进行了永久烘烤.可以在此处此处.

So, Invoke-WebRequest in Powershell Core is permanently baked with -UseBasicParsing. More details can be found here and here.

最终结果-结果对象上没有ParsedHtml属性.

Net result - no ParsedHtml property on the result object.

虽然基本原理很合理,但问题是-如何在Powershell Core中解析HTML?

While the rationale makes perfect sense, the question is - how to parse HTML in Powershell Core?

现在,我可能可以使用.NET Core库,例如 HtmlAgilityPack ,但似乎例如迁移现有的PS代码以使用此库将需要进行大量代码更改.

Now, I can probably use a .NET Core library, like HtmlAgilityPack, but it seems like vast code changes would be required to migrate existing PS code to use this library.

这是我们的最佳选择,还是PS Core用户有更好的选择?

Is this our best option or are there any better ones for PS Core users?

编辑1

似乎在这里找到了答案-无法使用IHTMLDocument2

The answer seems to be found here - Unable to use IHTMLDocument2

推荐答案

可能最简单的方法是使用powerHTML模块,该模块基本上为HTML Agility Pack提供了包装器

Probably the easiest way is to use powerHTML module which basically provides a wrapper for HTML Agility Pack

PowerHTML

这篇关于如何在Powershell Core中解析html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆