Home > Software design >  Is there a way to list all image links/urls found on a webpage?
Is there a way to list all image links/urls found on a webpage?

Time:11-03

I am currently trying to create my first Chrome extension. Basically what it will do is:

  1. Collect all image links from the current webpage
  2. Process each image through a filter (using the HTML img src / image link)
  3. Depending on an image's result after being processed, it will be replaced with another image

So far I have managed to work the filter and image replacement, but the problem I have is getting the actual URLs from the webpage. I've tried using document.getElementsByTagName("img") , but to be honest I'm just starting and don't really understand its function...

The extension will run in the background, always collecting, processing, and replacing images. So I think I would need the image urls to be listed so that they can be processed one by one.

Thanks so much in advance for your help (and patience)

CodePudding user response:

You might want to check out something like JSSoup if you're developing it in JS or Beautifulsoup4 if you're working in Python.

CodePudding user response:

The quickest way to get this done is with the help of Google's crawler. You could use it to search for image files on a given website, but you might have better luck if you specify that Google should avoid crawling images. Here are the steps:

With your browser, go to http://www.google.com/webmasters/tools .

Click the Crawl tab. In the "Crawl Settings" section, click "Sitemaps".

In the Sitemap subsection, select Never for Images.

Include sitemap in your site map: http://example.com/sitemap_index.xml You can find more information about the Google Webmaster tools at this page: for design of images you can also check vigo

  • Related