使用 C# 从 html 页面检索 javascript 属性

Retrive javascript properties from html page using C#

我想知道是否有办法使用 c# 从网页中获取特定 属性 的 javascript 函数,

这是我在站点中找到的功能:

(function($){
window.Ibles.pageContext = $.extend(window.Ibles.pageContext, {         
    numStepsByWordCount: 1,
    allSteps: true,
    ibleID: "EPAOKDUH8I455QP",
    ibleUrl: "/id/PVC-longbow/",
    ibleType: "Step by Step",
    ibleCategory: "outside",
    ibleChannel: "survival"
});
})(jQuery);

我需要获取 ibleID 属性。

感谢

您可以使用正则表达式轻松提取值:

var match = Regex.Match(content, "ibleID: \"(?<id>\w+)\"");

if (match.Success)
{
    var id = match.Groups["id"].Value;
}
else 
{
    // id not found
}