Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var page = require('webpage').create();
- page.open("http://n1k0.github.io/casperjs/#phantom_Casper_captureSelector", function (status) {
- if (status !== 'success') {
- console.log('Unable to load the address!');
- } else {
- var clipRect = page.evaluate(function () {
- return document.querySelector(".span7 demo").getBoundingClientRect(); });
- page.clipRect = {
- top: clipRect.top,
- left: clipRect.left,
- width: clipRect.width,
- height: clipRect.height
- };
- window.setTimeout(function () {
- page.render('capture.png');
- phantom.exit();
- }, 200);
- }
- });
- var clipRect = page.evaluate(function () {
- return document.querySelector(".span7 demo").getBoundingClientRect(); });
- var clipRect = document.querySelector(".span7 demo").getBoundingClientRect(); });
- var page = require('webpage').create();
- page.open("http://n1k0.github.io/casperjs/#phantom_Casper_captureSelector", function (status) {
- if (status !== 'success') {
- console.log('Unable to load the address!');
- } else {
- window.setTimeout(function () {
- //Heres the actual difference from your code...
- var bb = page.evaluate(function () {
- return document.getElementsByClassName("span7 demo")[0].getBoundingClientRect();
- });
- page.clipRect = {
- top: bb.top,
- left: bb.left,
- width: bb.width,
- height: bb.height
- };
- page.render('capture.png');
- phantom.exit();
- }, 200);
- }
- });
- var page = require('webpage').create();
- page.open("https://www.sejlar.com/maps.html", function (status) {
- if (status !== 'success') {
- console.log('Page not found');
- }
- else {
- var p = page.evaluate(function () {
- return document.getElementById('map').getBoundingClientRect();
- });
- page.clipRect = {
- top: p.top,
- left: p.left,
- width: p.width,
- height: p.height
- };
- page.render('screenshot.png');
- phantom.exit();
- }
- });
- return JSON.stringify(document.getElementsByClassName("span7 demo")[0].getBoundingClientRect();
- return JSON.stringify(document.getElementsByClassName("span7 demo")[0].innerHTML);
Add Comment
Please, Sign In to add comment