Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用HtmlAgilityPack解析html文档中的JSON变量?_C#_.net_Parsing_Html Agility Pack - Fatal编程技术网

C# 如何使用HtmlAgilityPack解析html文档中的JSON变量?

C# 如何使用HtmlAgilityPack解析html文档中的JSON变量?,c#,.net,parsing,html-agility-pack,C#,.net,Parsing,Html Agility Pack,我得到了以下html文档: document.html <head> <!-- head stuff --> </head> <body> <!-- lot of html --> <script> yt.setConfig({ 'VIDEO_ID': null, 'IS_UNAVAILABLE_PAGE': true <!-- I want to get true from

我得到了以下html文档:

document.html

<head>
  <!-- head stuff -->
</head>

<body>
  <!-- lot of html -->

  <script>
    yt.setConfig({
    'VIDEO_ID': null,
    'IS_UNAVAILABLE_PAGE': true  <!-- I want to get true from here -->
    });
  </script>
</body>

HtmlAgilityPack旨在解析HTML,而不是JS

由于JS不是HTML,因此允许您使用正则表达式解析一个简单的javascript字符串:

new Regex("'IS_UNAVAILABLE_PAGE': (?<value>true|false)");
newregex('IS_UNAVAILABLE_PAGE':(?true | false));
但是,如果您想在运行时找出变量的实际内存值,HtmlAlityPack和Regex都不能帮助您

new Regex("'IS_UNAVAILABLE_PAGE': (?<value>true|false)");