double820122 2018-11-20 19:58
浏览 70

laravel 5.7中返回变量的问题

I use Laravel 5.7. Websites are visible when the program is in progress but When done (return function) don't show all website in page. I think The problem of the return episode but I can't fix it.

Function

public function sls(Request $request){
    $ip = $request->input('ip');
    $cnt=1;
    $count=0;
    ini_set('max_execution_time', 600);
    $nextpage=true;
    while($nextpage==true){
        if($cnt==1)
            $url="https://www.bing.com/search?q=ip%3A".$ip."&qs=n&form=QBRE&pq=ip%3A".$ip."&sc=0-0&sp=-1&sk=";
        else
            $url="https://www.bing.com/search?q=ip%3a".$ip."&qs=n&sp=-1&pq=ip%3a".$ip."&sc=0-15&sk=&cvid=75D6BFCE5DF344E083DF2C10D5B735E9&first=".$cnt."&FORM=PERE";

        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        $result=curl_exec($ch);
        $myPattern = "#<cite>(.*?)</cite>#" ;

        if(preg_match_all($myPattern,$result,$find)){
            $urls = preg_replace("/<\/?strong>/","",$find[1]);
            $keys = array_filter($urls);
            $html = '<ul>';
            foreach($keys as $value){
                $count += 1;
                $html .= '<li> '.$count.'.'.$value.' </li>';
            }
            $html .= '</ul>';
            echo $html;
        }
        if(preg_match('/class="sb_pagN sb_pagN_bp b_widePag sb_bp "/',$result))
            $cnt+=40;
        else
            $nextpage=false;
    }
    return back()->with('list', $html);

Form

<form action = "" method = "post">
<input type = "hidden" name = "_token" value = "<?php echo csrf_token() ?>">

<table>
    <tr>
        <td>Server list site: </td>
        <td><input type="text"  name="ip" /></td>
    </tr>
</table>

{!! session('list') !!}

  • 写回答

2条回答 默认 最新

  • doupo1890 2018-11-20 20:15
    关注

    You are over writing the older pages with the last page.

    Make the below changes:

    $html = '';
    

    Add the above before the while.

    $html .= '<ul>';
    

    Change to the above line.

    This will allow all the websites to be included in the $html variable.

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器