Google analytics CasperJS captureSelector不捕获选择器,而是捕获整个页面

Google analytics CasperJS captureSelector不捕获选择器,而是捕获整个页面,google-analytics,casperjs,Google Analytics,Casperjs,我有一个谷歌分析仪表盘。 我只想使用捕获仪表板的特定部分 无论我尝试了什么,它都能捕获整个页面 我做错了什么? 这是我在检查Google Analytics仪表板时发现的HTML层次结构: <div id="ID-view"> <div class="_GAeH" id="ID-dashboard"> <div id="ID-layout"> <div class="_GARW ">

我有一个谷歌分析仪表盘。 我只想使用捕获仪表板的特定部分

无论我尝试了什么,它都能捕获整个页面

我做错了什么?

这是我在检查Google Analytics仪表板时发现的HTML层次结构:

<div id="ID-view">
    <div class="_GAeH" id="ID-dashboard">
       <div id="ID-layout">
          <div class="_GARW ">
             <div class="_GAoA">
                <!-- more <div>s with the content -->
             </div>
          </div>
       </div>
    </div>
</div>

CasperJS代码段:

var casper = require('casper').create();

casper.start('https://www.google.com/analytics/web/the/rest/of/the/url/', function() {
    this.fill('form#gaia_loginform', { 'Email': 'user', 'Passwd':'pass' }, true);
});

casper.waitForSelector('.ID-row-4-0-0', function() {
    casper.page.paperSize = {
        height: '11in',
        width: '8.5in',
        orientation:'portrait',
        border: '0.4in'
    };

// NONE of these work the way I think they should
// this.captureSelector('ga.pdf','#ID-view');
// this.captureSelector('ga.pdf','#ID-dashboard');
// this.captureSelector('ga.pdf','#ID-layout');
this.captureSelector('ga.pdf','._GAoA');
// this.captureSelector('ga.pdf','._GARW'); // <-- this one fails, capture height is messed up
},
function() {
    this.echo("Timeout reached");
});

casper.run();
var casper=require('casper').create();
卡斯珀,开始https://www.google.com/analytics/web/the/rest/of/the/url/,函数(){
this.fill('form#gaia#u loginform',{'Email':'user','Passwd':'pass',true);
});
casper.waitForSelector('.ID-row-4-0-0',function(){
casper.page.paperSize={
高度:“11英寸”,
宽度:“8.5英寸”,
方向:'肖像',
边框:“0.4英寸”
};
//这些都不是我认为应该的工作方式
//this.captureSelector('ga.pdf','#ID view');
//这个.captureSelector('ga.pdf','#ID dashboard');
//this.captureSelector('ga.pdf','#ID layout');
这个.captureSelector('ga.pdf','u GAoA');
//这个.captureSelector('ga.pdf','.\u GARW');//试试这个:

this.captureSelector('ga.pdf','div._GAoA', {quality: 100});
如果你不能拍摄元素的截图,请分享你的casperjs scrpit的输出


祝你好运。

我给出了……经过几个小时的努力,以PDF格式输出,我发现PhantomJS中似乎有一个问题已经两年多没有解决了。建议使用溢出和iframes。你试过了吗?如果你能提供一个答案,那就太好了。我没有答案。我放弃了这个Casper的想法,开始吧我想尝试一个不同的想法。谢谢分享,但我完全放弃了这个想法,转而去了另一个方向