Re: Parsing Javascript simply


Quincey Morris
 

On Dec 2, 2019, at 17:35 , Graham Cox <graham@...> wrote:

My question is, is there a way to run the Javascript using some built-in classes to get the final page rendering, so that the video address can be obtained? I don’t want to write my own Javascript parser, that’s crazy. Besides, I don’t know Javascript very well, so I’d rather just leave it to some existing code, then make use of its output. Is this possible, or what strategy can I use?

I tried something similar recently, and got better-than-anticipated results using this NSAttributedString initializer:


IIRC, this gave me an attributed string with (Javascript-generated) links embedded, so you might have to scan for ”a” tags instead of “video” tags. I dunno, it might not work for you, but it should be simple to try.

Join {cocoa@apple-dev.groups.io to automatically receive all group messages.