On 26 Mar 2002 at 7:05, Tony Lewis wrote: > Csaba R�duly wrote: > > > I see that wget handles <SCRIPT> with tag_find_urls, i.e. it tries to > > parse whatever it's inside. > > Why was this implemented ? JavaScript is most > > used to construct links programmatically. wget is likely to find > > bogus URLs until it can properly parse JavaScript. > > wget is parsing the attributes within the <script> tag, i.e., <script > src="url">. It does not examine the content between <script> and </script>.
I think it does, actually, but that is mostly harmless. I haven't heard of any cases where it has caused a problem (assuming the script is well-formed). It's normal good practice to hide the code in a HTML comment anyway, but perhaps that good practice is less common now these days now that virtually every browser out there groks <SCRIPT></SCRIPT> and <NOSCRIPT></NOSCRIPT>. Wget's HTML parser doesn't yet have the hooks to allow different elements (such as SCRIPT and STYLE) to be processed differently to normal HTML. If it gets these hooks it could then go off and process the SCRIPT element differently. (The minimal processing for the SCRIPT element, if it is using an an unsupported script language would be to skip it.) If a future version of Wget were to handle JavaScript as an option (perhaps using the GPL'd SpiderMonkey), it would have to parse the default action of the script and also possibly exercise the various event handlers to gather more URLs. I guess this would fail on the more complicated scripts that expect some sort of intelligent being (or a suitably programmed robot) to fill in forms and/or press buttons in the correct sequence to progress to the next page!
