Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

consigliere's avatar

How to get all the images including the ones in the background(css) of a site using php?

Hi,

Is there an easy way to do it in PHP?

I'm using Goutte package but could only get the "img" nodes.

0 likes
3 replies
kobear's avatar

Not really sure what you are looking to do here. Are you looking for an automated way to go to a URL and download all the graphics on the page, including those referenced in via CSS?

If so, JavaScript is probably better at this than PHP

mehany's avatar

@kobear agree. Doing this with PHP will end up running in several limitations, I would do this with nodeJS and selenium instead. With selenium, you can automatically open a browser, inject scripts to read images, links and possibly grap the link of css files, download them locally then parse them as needed with any language.

1 like

Please or to participate in this conversation.