简体   繁体   中英

How to identify a particular image in a website fetched from a particular CDN server?

For example: There is a website which contains few images,a HTML document,and other contents. Now i want to find out the images used or displayed in the website where fetched from which CDN(Content Delivery Network) server? and likewise for HTML documents and for all contents present in the website. Can anyone help me on this one??

You could iterate over all the imgs / other elements that you are referencing in your code and check the domain names. This should give you a list of items which may or may not be originating from a CDN.

var hosts = [];

$('img').each(function(i, e) {
    var h = $(e).attr('src').match(/^http:\/\/[^/]+/)[0];
    if (hosts[h] == undefined) hosts[h] = 0; 
    hosts[h]++;
});

console.log(hosts);

The above code lists all the domains for images on a page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM