开发者

php parse javascript generated text

开发者 https://www.devze.com 2023-03-29 15:38 出处:网络
let\'s say that on some site there are some div elements, which content is generated by javascript. I want to code a PHP s开发者_开发问答cript, that will get that content and store it to some variable

let's say that on some site there are some div elements, which content is generated by javascript. I want to code a PHP s开发者_开发问答cript, that will get that content and store it to some variable. I know how to parse text using PHP, I just don't know how to get to the javascript generated output (not JavaScript code!) and store it to PHP variable. Any ideas?


You could post the HTML back to your PHP script. Assuming that the javascript code fills out an element with id="foo"...

var generatedHTML = document.getElementById('foo').innerHTML;

Then you could use whatever AJAX library you might have (eg: jQuery) to post it to a server for processing.

(Or you could process it on the client side..!)

0

精彩评论

暂无评论...
验证码 换一张
取 消