Interpreting JavaScript in PHP -


i'd able run javascript , results php , wondering if there library php allows me parse out. first thought use node.js, since node.js has access sockets, files , things think i'd prefer avoid that.

rationale: i'm doing screen scraping in php , have encountered many scenarios data being produced javascript on frontend, , avoid writing specialized filtering functions act on javascript on per-case basis since takes lot of time. more general case parse javascript directly.

downvoting: don't see what's controversial question, modern web crawlers known it, difference tend not written in php. [1]

[1] http://blogs.forbes.com/velocity/2010/06/25/google-isnt-just-reading-your-links-its-now-running-your-code/

it's interesting question , down-voters being unimaginative potential use-cases. page archiving tools, printing scripts, preview images - valid reasons want manipulate document javascript included within page.

i'm not aware of existing php implementations, adapt mozilla's spidermonkey php module, or standalone tool manipulate domdocument , return result.

i haven't had experience server-side javascript, issues believe might need dealt with:

  • host objects document , window not part of ecmascript specification (these objects provided implementing browser) need make sure library provides equivalent host objects.
  • you might have security issues around executing client side scripts within server side environment. lot allowing user submit php script evaluation, need make sure security sandbox tight.

another (perhaps) safer , easier implement option might use modified firefox or webkit instance runs browser, loading target pages , returning modified source application.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -