【问题标题】:find and replace html contents from remote iframe从远程 iframe 中查找和替换 html 内容
【发布时间】:2014-03-24 19:03:33
【问题描述】:

从远程主机中提取捕获的 iframe 代码。

  <div class="ad-title">
                        <span class="pointer" onclick="window.open('surfv.php?view=surfer&f=1&t=f97e5cec351c254254c290577e6a&p=78r254sfsv46s224&u=1','_blank');">Link1 Name</span>  
                    </div>

        <p class="adimg"><img src="http://domain.com/banner_7.png"  style="max-height:50px; max-width:200px;;border:0px;"/></p>
                               <div class="ad-content">



        <table cellpadding="5" width="100%"><tr>
             <td valign="top"><span style="font-family:  Verdana, Sans-serif; font-size:13px; ">Add title</span></td>
             </tr>
             </table>
                    </div>
赚 $ 0.0005

我已经捕获了远程 iframe 并阅读了代码。

$homepage = file_get_contents('http://remotehost.com/iframe.php');
echo $homepage;
?>

代码摘录如上所示

我要抓拍

surfv.php?view=surfer&f=1&t=f97e5cec351c254254c290577e6a&p=78r254sfsv46s224&u=1

Link1 名称 $0.0005

从此框架中,并将它们按以下格式放入新表中。 新链接=`http://mywebsite.com/surfv.php?view=surfer&f=1&t=f97e5cec351c254254c290577e6a&p=78r254sfsv46s224&u=1

NewLink Title= Link1 Name
Price= $0.0005
--------------

感谢帮助`

【问题讨论】:

    标签: php html regex iframe


    【解决方案1】:
    <?php
    function gsb($string, $start, $end)
    {
        $string = " " . $string;
        $ini    = strpos($string, $start);
        if ($ini == 0)
            return "";
        $ini += strlen($start);
        $len = strpos($string, $end, $ini) - $ini;
        return substr($string, $ini, $len);
    }
    $homepage = file_get_contents('http://remotehost.com/iframe.php');
    $link="http://mywebsite.com/".gsb($homepage,"window.open('","'");
    echo $link;
    

    【讨论】:

    • 感谢您的帮助-我会尝试然后回来。
    • 它出现了很多 window.open('surfv.php ... 我试图实现代码但它没有捕获所需的链接,否则它会捕获第一个链接 window.open(' surfv.php 并显示它...感谢更多建议
    • 它采用 window.open( -- 我想捕获以 surfv.php 开头的链接?,并修改它...感谢更多建议。
    猜你喜欢
    • 2014-06-13
    • 2018-07-05
    • 2022-01-06
    • 2021-10-04
    • 1970-01-01
    • 2021-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多