I have written previously a blog article that I explained in detail how I fetch the image URL from a website using Power Query. That method, however, is what I call a bit of a techie way of doing it because you have to look at the HTML code of the page. There is an easier way of doing it as well. For this method, you don’t need to look at the code at all. I am going to explain it in this post. If you like to learn more about Power BI, read Power BI book from Rookie to Rock Star.
Get Data from Web
In Power BI (Power Query), when you get data from web, you get a list of tables suggested by the graphical interface of Power Query. However, those tables, usually cover the data, not link URLs, or image URLs. the below example, is what I get when I use Get Data from Web of this URL for IMDB top 250 movies: https://www.imdb.com/chart/top
Add Table Using Examples
If you click on Add table using examples button (mentioned in the screenshot above), You will get a graphical editor, that you can enter some sample values, and tell to Power Query what is the value you are looking for, then Power Query will search for those values in the page, and use that structure as a template.
The Add table using examples is particularly good when the data you want to fetch from the page is not in an HTML table, The example below, shows that I get data even from part of the page that is not a table. With just providing the first two values of any list, as an example, Power Query will find the structure to locate the section and get the remaining values;
Image URLs
The same method can be used for Image URLs. First, you need to get a couple of Image URLs as an example. If you use Google Chrome as a browser, on the right click on an image, you can get the option for it; Copy image address
Now in the Add table using examples, paste that value in the first cell;
Do this process one more time for the second image in the list,
Easy, wasn’t it? now you got all the image URLs!
You can also add the other information for each movie, so you can find out what movie’s image it is. You can also rename columns to whatever you like, and then load that data into Power BI.
Now these image URLs, can be loaded into Power BI, with the Data Category as image,
and you can have a visual like this:
What if this method doesn’t work?
There is a possibility that this method doesn’t work. Depends on the complexity of HTML code, and even sometimes similarity of blocks and values on the page, this method might not give you exactly what you want. If you cannot get this method to work, I strongly recommend you to do it using the other method I explained in my other article.
I hope this quick tip helps you to get the image URLs that you want even much simpler and faster, using Power Query.