Power Query web scrape

gargamalebarbosa

Board Regular
Joined
Aug 4, 2022
Messages
118
Office Version
  1. 365
Platform
  1. Windows
Hi ,
I want to retrieve fuel price archives from the URL below. There are 3 criteria. 1. City name. 2. District name. 3. Date range. After entering these criteria and clicking the search button, I want to fetch the resulting table using Power Query. Is this possible?

Thank you all.






1696281165848.png
 
You have chosen the method would be the method, I would have preferred too.
It seems we have a lot to learn from you.
I'm going to bother you from time to time, I hope you don't mind.

(Sağlıcakla)
You are welcome to ask any Excel-related question on the MrExcel Message Board. Honestly, I can barely find chance to answer questions but the board is full of brilliant Excel experts who would be happy to help.

Welcome to the MrExcel Message Board!
 
Upvote 1

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi @smozgur,

Based on the tutorial codes you wrote on this topic, we got data from the Opet website. It was very enjoyable.

Afterwards, I needed to pull the fuel prices of two other companies due to my job.

Unfortunately, I couldn't even do anything because Shell doesn't provide an api.

BP, on the other hand, provided api and I prepared the following codes.

Power Query:
let
    sehirAdi  = Excel.CurrentWorkbook(){[Name="sehirAdi"]}[Content][Column1]{0},
    Source =  Json.Document(Web.Contents("https://www.bp.com/bp-tr-pump-prices/api/PumpPrices?strCity=" & sehirAdi, [Headers=[#"User-Agent"="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36"]])),
    ConvertToTable = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    ExpandRecords = Table.ExpandRecordColumn(ConvertToTable, "Column1", {"District", "Benzin", "GazYagi", "BenzinUltimate", "MotorinUltimate", "Motorin", "FuelOil","KaloriferYakiti","FuelOilYuksekKukurt","LpgPrice"}),
    ReorderColumns = Table.ReorderColumns(ExpandRecords,{"District", "Benzin", "GazYagi", "BenzinUltimate", "MotorinUltimate", "Motorin", "FuelOil","KaloriferYakiti","FuelOilYuksekKukurt","LpgPrice"})
in
    ReorderColumns

If you have time (it is not a critical need), can we ask you for help in retrieving data from the Shell and BP site? so that I can transfer the data according to the CITY, DISTRICT information and DATE information I will select.
 
Upvote 0
BP, on the other hand, provided api and I prepared the following codes.
I don't see any problem with your code above. I think you got it.

If you have time (it is not a critical need), can we ask you for help in retrieving data from the Shell and BP site? so that I can transfer the data according to the CITY, DISTRICT information and DATE information I will select.
Even if your question is similar to another question on the board, you should start your own thread since it is a new question unless it is about the provided solution in the existing thread, i.e. the you can't run the provided code in its context. This ensures that your question gets proper attention from other members, and you can also include a link to the existing thread as a reference if it's relevant.
 
Upvote 0
Thank you for your feedback.
I will open a new question.
 
Upvote 0

Forum statistics

Threads
1,223,936
Messages
6,175,508
Members
452,650
Latest member
Tinfish

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top