从外部网站获取所有脚本

发布于 2024-12-20 23:24:39 字数 1297 浏览 5 评论 0原文

我这里有一些代码,我用这个代码渲染外部页面(类似于 iframe),但我得到了源代码。但是当我开始我的代码时,一切都很好,但那里显示一个窗口,我无法关闭它来查看内容。这是代码: 代码:

<?php

$url = 'http://www.kupime.com/';

$data = file_get_contents($url);

$data = '<head><base href='.$url.' target="_blank" /></head>'.$data;

echo $data;

?>

这会生成一个很好的 HTML 页面,但要关闭窗口,我还需要使用此书签获取所有脚本

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();
    }
})();

但是我如何在上面的代码中实现这一点?这是第一个演示(仅 php 代码) http://www.pluspon.com/get1.php< /a> 或者也许用一些 wget 来做到这一点?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

惟欲睡 2024-12-27 23:24:39

黑客方式:如果你只是想摆脱窗口,你只需要添加隐藏该窗口元素的CSS。

<style>
#home_banner_campaign_wrapper,#active_banner_wrap {display:none;}
</style>

by,嗯..也许是这样的:

<?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;
?>

如果这种方式太愚蠢了,请原谅我..

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..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文