问题
I have a some code here and I with this code render external page (similar to iframe) but I got a source code. But when I start my code all is good but one window is showing there and I can't to close his to see contents. Here is the code: Code:
<?php
$url = 'http://www.kupime.com/';
$data = file_get_contents($url);
$data = '<head><base href='.$url.' target="_blank" /></head>'.$data;
echo $data;
?>
and this generate a good HTML page but to close window I need also to get all scripts with this bookmarklet
javascript: (function(){
s = document.getElementsByTagName('SCRIPT');
tx = '';
sr = [];
for (i = 0; i < s.length; i++) {
with (s.item(i)) {
t = text;
if (t) {
tx += t;
}
else {
sr.push(src)
};
}
};
with (window.open()) {
document.write('<textarea%20id="t">' + (sr.join("\n")) + "\n\n-----\n\n" + tx + '</textarea><script%20src="http://jsbeautifier.org/beautify.js"></script><script>with(document.getElementById("t")){value=js_beautify(value);with(style){width="99%";height="99%";borderStyle="none";}};</script>');
document.close();
}
})();
But how can I implement this in my code above? Here is the demo of first (only php code) http://www.pluspon.com/get1.php or maybe to do this with some wget?
回答1:
hack way : if you just want to get rid of the window, you just need to add css that hide that window element.
<style>
#home_banner_campaign_wrapper,#active_banner_wrap {display:none;}
</style>
by, umm..perhaps like this :
<?php
$url = 'http://www.kupime.com/';
$data = file_get_contents($url);
$style = '<style>#home_banner_campaign_wrapper,#active_banner_wrap {display:none;}</style>';
//insert the style just before the closing head tag
$data = str_replace('</head>', $style.'</head>', $data);
$data = '<head><base href='.$url.' target="_blank" /></head>'.$data;
echo $data;
?>
well pardon me if this way is too stupid..
来源:https://stackoverflow.com/questions/8504757/get-all-scripts-from-external-website