I'm trying to find a method of accessing data between tags returned by a server I am making HTTP requests to. The document has multiple tags, but only one of the tags has JavaScript code between it, the rest are included from files. I want to accesses the code between the script tag.
An example of the code is:
<html>
// Some HTML
<script>
var spect = [['temper', 'init', []],
['fw/lib', 'init', [{staticRoot: '//site.com/js/'}]],
["cap","dm",[{"tackmod":"profile","xMod":"timed"}]]];
</script>
// More HTML
</html>
I'm looking for an ideal way to grab the data between 'spect' and parse it. Sometimes there is a space between 'spect' and the '=' and sometimes there isn't. No idea why, but I have no control over the server.
I know this question may have been asked, but the responses suggest using something like HTMLAgilityPack, and I'd rather avoid using a library for this task as I only need to get the JavaScript from the DOM once.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…