brendan
brendan

Reputation: 1735

Using Perl to Extract script type html/text

I am currently trying to extract the page that a script type="text/html" points to. For example this CNN link has the line in the source:

<script type="text/html" id="pageTemplate"></script>

I want to download the contents of pageTemplate and be able to parse the results. I have been trying to use HTML::TagParser and I am able to get the element pageTemplate, but I can not get its contents.

Upvotes: 1

Views: 442

Answers (1)

wholerabbit
wholerabbit

Reputation: 11546

As is, "pageTemplate" doesn't have any contents. Presumably, that's because it's going to be used as a stash for some html; scripts of type "text/html" don't actually do anything. Ie, a <script> like this is an undisplayed DOM element that could be put to whatever purposes.

One possibility: http://ejohn.org/blog/javascript-micro-templating/

Look thru the javascript associated with the CNN page for clues about what that id is being used for.

Upvotes: 3

Related Questions