web-scrapingphantomjs

Is it possible to detect SSL-Sites that have included "insecure content" in PhantomJS


I want to automatically check if a HTTPS page includes "insecure content" eg HTTP content.

Is there a way to automatically determine that?

It seems phantom just loads the content and ignores that fact.


Solution

  • This works like a charm:

    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();
    });