0

The JSON I wish to use is embedded on a HTML page. Within a tag on the page there is a statement:

<script>
jsonRAW = {... heaps of JSON... }

Is there a parser to extract this from HTML? I have looked at json.NET but it requires its JSON reasonably formatted.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
John Hartley
  • 483
  • 1
  • 6
  • 16

1 Answers1

2

You can try to use HTML Agility pack. This can be downloaded as a Nuget Package. After installing, this is a tutorial on how to use HTML Agility pack. The link has more info but it works like this in code:

var urlLink = "http://www.google.com/jsonPage"; // 1. Specify url where the json is to read. 

var web = new HtmlWeb(); // Init the HTMl Web

var doc = web.Load (urlLink); // Load our url

if (doc.ParseErrors != null) { // Check for any errors and deal with it. 
}

doc.DocumentNode.SelectSingleNode(""); // Access the dom.

There are other things in between but this should get you started.

Gauravsa
  • 6,330
  • 2
  • 21
  • 30