php : parse html : extract script tags from body and inject before </body>?
问题 I don't care what the library is, but I need a way to extract <.script.> elements from the <.body.> of a page (as string). I then want to insert the extracted <.script.>s just before <./body.>. Ideally, I'd like to extract the <.script.>s into 2 types; 1) External (those that have the src attribute) 2) Embedded (those with code between <.script.><./script.>) So far I've tried with phpDOM, Simple HTML DOM and Ganon. I've had no luck with any of them (I can find links and remove/print them -