I'm trying to get a table from a webpage, but I cannot seem to get PowerBI to correctly load that page.
The table I'm trying to import is the GOLD KOERSEN
table, highlighted in yellow in this screenshot.
However, after entering the url, I get
Followed by DataSource.Error
We were unable to retrieve the contents of the web page.
I already tried adding HTTP request headers
and Command timeout
but nothing seems to work.
I also tried to first use a different (working) webpage, and modify the url in the Source
step
Source = Web.BrowserContents("https://www.w3schools.com/html/html_tables.asp")
changed to
Source = Web.BrowserContents("https://www.argentorshop.be/verkoop-uw-edelmetaal-aan-argentorshop/verkoop-uw-goudstaven-en-of-gouden-munten-aan-argentor/")
but it yields the same error.
Also, trying to wait for a specific Selector
in the options
of Web.BrowserContents(url,options) by using [WaitFor = [Selector = "#verkopen > div.bootstrap-table"]]
doesn't do the trick.
Does anyone know of a way to correctly import that table in PowerBI?
Try this.
let
Source = Web.Contents(
"http://www.argentorshop.be/nl/graphql",
[
Headers=[
#"Method"="POST",
#"Content-Type"="application/json"
],
Content=Text.ToBinary("{""query"": ""{sellMetalsGrid (metals: [GOLD]){products {entity_id,name,purchasing_price,buying_premium,spread_percentage,spread_currency,selling_premium,price,image,short_description,product_type,fine_metal_content,metal,url,stock_status}}}""}")
]
),
#"JSON" = Json.Document(Source),
data = JSON[data],
sellMetalsGrid = data[sellMetalsGrid],
products = sellMetalsGrid[products],
#"Converted to Table" = Table.FromList(products, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"entity_id", "name", "purchasing_price", "buying_premium", "spread_percentage", "spread_currency", "selling_premium", "price", "image", "short_description", "product_type", "fine_metal_content", "metal", "url", "stock_status"}, {"Column1.entity_id", "Column1.name", "Column1.purchasing_price", "Column1.buying_premium", "Column1.spread_percentage", "Column1.spread_currency", "Column1.selling_premium", "Column1.price", "Column1.image", "Column1.short_description", "Column1.product_type", "Column1.fine_metal_content", "Column1.metal", "Column1.url", "Column1.stock_status"})
in
#"Expanded Column1"