# web scraping images

I am trying to load player profile pictures from the following page:

https://www.transfermarkt.com/manchester-united/startseite/verein/985/saison_id/2006#

I use the following code:

Import["https://www.transfermarkt.com/manchester-united/startseite/\
verein/985/saison_id/2006#", "Images"]


Unfortunately, all profile images are loaded as follows:

All images I do not need are in the correct format...

The pause function (e.g., for one second)

Pause[1]


only works between tasks. So I do not think I can use it.

Any ideas how to solve this issue?

If you write an HTML img tag like this:

<img src="url/to/image.jpg">


then the image will be downloaded directly upon page load. Some frontend developers don't like this as they think it's more important to quickly show the bulk of the page. The images can come later. So what they did in this case was writing

<img data-src="url/to/image.jpg">


They then use JavaScript to get the URLs from the data-src attributes and load the images that way. Clearly, this is not something that Import can figure out. However, using this knowledge, we can do it quite easily with jsoupLink:

<< jsoupLink

html = Import[
"https://www.transfermarkt.com/manchester-united/startseite/verein/985/saison_id/2006#",
"HTMLDOM"
];
images = html["Select", ".bilderrahmen-fixed"];
images = Import[#["Attribute", "data-src"]] & /@ images;
Partition[images, 8] // Grid
`

• Perfect, thanks a lot! – Philippe Dufour Aug 28 '19 at 18:13