0

ページ全体の loc タグ テキストを抽出し、抽出されたすべてのテキストの数を取得する必要があります。次のコマンド casper.open(' http://www.raybiztech.com/ .....') をループで繰り返します。反復。上記のシナリオに役立つものはありますか

<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
        <url>
            <loc>http://raybiztech.com/blog</loc>
            <lastmod>2014-02-24</lastmod>
        </url><url>
            <loc>http://raybiztech.com/blog/application-development-maintenance</loc>
            <lastmod>2014-02-14</lastmod>
        </url><url>
            <loc>http://raybiztech.com/blog/application-development-maintenance/analysis-services-testing-with-nick</loc>
            <lastmod>2014-02-14</lastmod>
        </url><url>
            <loc>http://raybiztech.com/blog/application-development-maintenance/bi-solution-join-on-premises-to-windows-azure</loc>
            <lastmod>2014-02-14</lastmod>
        </url><url>
            <loc>http://raybiztech.com/blog/application-development-maintenance/data-profiling-im-data-source-view</loc>
            <lastmod>2014-02-14</lastmod>
        </url><url>
            <loc>http://raybiztech.com/blog/application-development-maintenance/data-programmability-tools-with-craig-lee</loc>
            <lastmod>2014-02-14</lastmod>
 .....

以下のようにコードを更新しました。特に「loc」でテキストを抽出し、casper.thenopen(" http://raybiztech.com/blog ");で繰り返します。

var casper = new require('casper').Casper({
    verbose: true,          // log messages will be printed out to the console
    logLevel: "debug",              // "Debug" level messages will be logged        
    safeLogs: false,


});
    var fs = require('fs');
        var fname = new Date().getTime() + '.xml';
    var save = fs.pathJoin(fs.workingDirectory, 'raybiztech', fname);

casper.test.begin('Payment Gateway',function(test) {

/*
 * Start the browser with url http://lcdev.bluemodus.com/
 */
casper.start('http://www.raybiztech.com/sitemap.xml',function(){
    this.capture('/home/gopi/output/learningcounts/cmsHome.jpg');
    this.echo(this.getCurrentUrl());
    fs.write(save, this.getPageContent() + '\n', 'w');
    require('utils').dump(this.getElementsInfo('loc'));


});
casper.viewport(1366,768);
casper.run(function() {
    test.done();
    casper.test.renderResults(true, 0, '/home/gopi/workspace/learningcounts/raybiztech.xml');
});
});
4

1 に答える 1