简体   繁体   中英

Retrive javascript properties from html page using C#

I want to know if there is a way to get specific property of javascript function from a webpage using c#,

here is the function I found within the site :

(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);

I need to get the ibleID property.

Thx before

You can extract the value easily by using a regular expression:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM