Website crawling...

Discussion in 'Programming' started by Web_Dev_Chris, May 11, 2020.

  1. #1
    Hi,

    This is my php script:
    <?php
        header("Content-Type: text/plain");
    
        $context = stream_context_create(
        array(
            "http" => array(
                "header" => "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"
                )
            )
        );
       
        $website = $_GET["URL"];
    
        $html = file_get_contents($website, false, $context);
    
        echo $html;
    ?>
    PHP:
    And I suppose the Javascript will pull the entire document with an AJAX call. The website I want to call will be a variable on the end of the script page.

    For example

    index.php?URL=http://www.google.com.au/

    The HTML source code will then be echo'd out into the page. The ajax request will pull that page. How can I do this asynchronously so that the php script has enough time to render the entire HTML source code before the AJAX pulls in the page?
     
    Web_Dev_Chris, May 11, 2020 IP