1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

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