Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
if (isset($_GET['url'])) {
$url = rawurldecode(trim($_GET['url']));
if (empty($url))
if (substr($url, 0, 4) != 'http')
$url = "http://{$url}";
require_once 'PHPWebDriver/__init__.php';
$wd_host = 'http://localhost:4444/wd/hub';
$WebDriver = new PHPWebDriver_WebDriver($wd_host);
$session = $WebDriver->session('firefox');
$session->window()->postSize(array('width' => 1366, 'height' => 768));
$img = $session->screenshot();
$data = base64_decode($img);
header("Cache-control: max-age=60");
header("Content-Length: " . strlen($data));
echo $data;
} else {
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<input type="text" id="url" name="url" placeholder="请输入网址" style="width: 600px"/>
<input type="button" id="go" value="Go" onclick="return go();" />
<img id="img" src="" onload="done()"/>
<script type="text/javascript">
function go() {
document.getElementById("go").value = "Loading";
document.getElementById("go").setAttribute("disabled", "disabled");
document.getElementById("img").setAttribute("src", "");
var url = encodeURIComponent(document.getElementById("url").value);
document.getElementById("img").setAttribute("src", "?url=" + url);
return false;
function done() {
document.getElementById("go").value = "Go";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.