简体   繁体   中英

How to get all javascript source links from a website url when the page download

I need to check a website if it uses a special online js source(for example, fontawesome).

By the way, some can be found only when it's loaded, not from website source html. I tried with puppeteer, but it takes long time. I think the reason is that it loads other resources like images.

Is there any solution for this? Thank you for your time.

If you are looking for the source you can do this within most browsers Chrome for example if you press Control+ Shift+I then select the sources tab , this will give you the sources of the web page. Are you looking for a script to automate this process?

This is solved by phantomjs

const phantom = require('phantom');
(async function() {
  const instance = await phantom.create();
  const page = await instance.createPage();
  await page.on('onResourceRequested', function(requestData) {
    console.info('Requesting', requestData.url);
  });

  const status = await page.open('https://stackoverflow.com/');
  const content = await page.property('content');
  console.log(content);

  await instance.exit();
})();

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