Save current page as HTML to server

后端 未结 6 1810
一生所求
一生所求 2020-11-29 19:05

What approach could someone suggest to save the current page as an HTML file to the server? In this case, also note that security is not an issue.

I

6条回答
  •  孤城傲影
    2020-11-29 19:31

    //function to use curl to get the content of the page.
    //parameter used url and $data for the posting credentials to retrieve information.
    
    function httpPost($url, $data){
        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    
        $response = curl_exec($curl);
        curl_close($curl);
        return $response;
    }
    
    //
    $filename="abc.html"; // whatever name you want.
    $myfile = fopen($filename, "w") or die("Unable to open file!");
    $txt =  httpPost(, ""); // replace by url you want.
    fwrite($myfile, $txt);
    fclose($myfile);
    

提交回复
热议问题