How do I capture a page as HTML?
If you bootstrap Drupal, you can just tell it to serve a particular page. Consider the content of index.php:

&lt;?php
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;
$autoloader = require_once 'autoload.php';

$kernel = new DrupalKernel('prod', $autoloader);

$request = Request::createFromGlobals();
$response = $kernel-&gt;handle($request);


If you replace the Request::createFromGlobals with a new Request(...), you can pass explicit values for the $_GET etc parameters. The function signature copied from Symfony is as follows:

/**
 * Constructor.
 *
 * @param array           $query      The GET parameters
 * @param array           $request    The POST parameters
 * @param array           $attributes The request attributes (parameters parsed from the PATH_INFO, ...)
 * @param array           $cookies    The COOKIE parameters
 * @param array           $files      The FILES parameters
 * @param array           $server     The SERVER parameters
 * @param string|resource $content    The raw body data
 */
public function __construct(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
{
    $this-&gt;initialize($query, $request, $attributes, $cookies, $files, $server, $content);
}


So your custom script could require the autoloader, bootstrap Drupal, create a fake Request object, tell Drupal to handle it, then save $response-&gt;getContent() to a file.