PHP УРОК Делаем зачетный скриншотер страницы сайта на 500 снимков в сутки
В редакторе
PHP УРОК Делаем зачетный скриншотер страницы сайта на 500 снимков в сутки
Brain_Script
1475
2017-03-23 19:41:11
{
"pages":[
{
"url": "http://codly.ru",
"content": null,
"urlSettings": {
"operation": "GET",
"encoding": "utf8",
"headers": {},
"data": null
},
"renderType": "jpg",
"outputAsJson": true,
"requestSettings": {
"ignoreImages": false,
"disableJavascript": false,
"userAgent": "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/534.34 (KHTML, like Gecko) Safari/534.34 PhantomJS/2.0.0 (PhantomJsCloud.com/2.0.1)",
"authentication": {
"userName": "guest",
"password": "guest"
},
"xssAuditingEnabled": false,
"webSecurityEnabled": false,
"resourceWait": 15000,
"resourceTimeout": 35000,
"maxWait": 35000,
"waitInterval": 1000,
"stopOnError": false,
"resourceModifier": [],
"customHeaders": {},
"clearCache": false,
"clearCookies": false,
"cookies": [],
"deleteCookies": []
},
"suppressJson": [
"events.value.resourceRequest.headers",
"events.value.resourceResponse.headers",
"frameData.content",
"frameData.childFrames"
],
"renderSettings": {
"quality": 100,
"pdfOptions": {
"border": null,
"footer": {
"firstPage": null,
"height": "1cm",
"lastPage": null,
"onePage": null,
"repeating": "%pageNum%/%numPages%"
},
"format": "letter",
"header": null,
"height": null,
"orientation": "portrait",
"width": null
},
"clipRectangle": null,
"renderIFrame": null,
"viewport": {
"height": 1280,
"width": 1280
},
"zoomFactor": 1,
"passThroughHeaders": false
},
"scripts": {
"domReady": [],
"loadFinished": []
}
}
],
"proxy":false
}
<?php
function base64_to_jpeg( $base64_string, $output_file ) {
$ifp = fopen( $output_file, "wb" );
fwrite( $ifp, base64_decode( $base64_string) );
fclose( $ifp );
return( $output_file );
}
$url = 'http://PhantomJScloud.com/api/browser/v2/ak-sa91e-86ms1-0d8nk-18390-nh1jq/';
$payload = file_get_contents ( 'request.json' );
$options = array(
'http' => array(
'header' => "Content-type: application/json\r\n",
'method' => 'POST',
'content' => $payload
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) { /* Handle error */ }
$obj = json_decode( $result );
$base64Enc = $obj->{"content"}->{"data"};
base64_to_jpeg( $base64Enc, $obj->{"content"}->{"name"} );
?>
Войдите для добавления комментария.