I implement a Chrome extension. The extension needs to get all images URLs of webpages. However, some webpages have "lazy load" plug-in. My question is if it is possible that I can still get URLs without required manually scrolling down?
How to force loading images for the webpages installed "lazy load" without scrolling?
3.5k views Asked by James Liu At
2
Many of the lazy-load plugins stores the actual URL in the data-* section. When scrolling down, right before the image tag gets into view the data-* content is set on the
src
attribute to start loading the image.You can iterate through all the image tags like this to find the links, for example:
But note that there is no naming standard for the data-* holder so different plugins will use different names - you'll have to collect these manually (f.ex. this plugin uses the name
data-original
, this one usesdata-layzr
and so on).You could possible do an addition step looping through the
dataset
collection to find any string which may seem to contain an URL (ifsrc
is empty), but also this is prone to errors as images from the same server often are relative links and data-* can hold other data too.