2013-03-26 84 views
0

中檢測到包含「不安全內容」的SSL站點我想自動檢查HTTPS頁面是否包含「不安全內容」,例如HTTP內容。是否有可能在PhantomJS

有沒有辦法自動確定?

似乎幻影只是加載內容並忽略這一事實。

回答

2

這就像一個魅力:

console.log('Loading a web page'); 

var page = new WebPage(); 
page.onResourceRequested = function(request) { 
    if(/^https/.exec(request.url)) { 
    console.log('i am fine with ' + request.url) 
    } else { 
    console.log('i dont like ' + request.url) 
    } 
} 

page.viewportSize = { width: 1024, height: 768 }; 
var url = "https://example.com"; 

page.open(url, function (status) { 
    if(status == 'success') { 
    page.render('test.png'); 
    console.log('loaded') 
    } 
    phantom.exit(); 
}); 
0

有趣的方法。謝謝。 我只是建議檢查它確實捕獲所有資源,並沒有打開與該事件相關的phantomjs錯誤。