-1

I am trying to scrape the current gas prices in a German city by using the IMPORTHTML-function in Google Sheets. The function seems to work, at least the data is being imported into my sheet. When taking a closer look, one recognizes, that the data inserted into the sheet differs from the current data displayed on the webpage I am scraping.

This is the function I inserted into my Google sheet:=IMPORTHTML("https://www.benzinpreis.de/aktuell/super_e5/deutschland/nordrhein-westfalen/koeln/koeln/koeln"; "table";4)

I took a screenshot of the differing values:

Screenshot of differing values

Does anyone have an idea where I made a mistake?

player0
  • 124,011
  • 12
  • 67
  • 124
SandraLie
  • 11
  • 4

1 Answers1

0

You may consider using external tools which can render JS website OR debug if the website makes some AJAX call, and get raw JSON instead of trying to fight with HTML. It looks like the website uses this xhr request to get the actual data in JSON: https://www.benzinpreis.de/bpmap-callback.php?lat_min=50.86707808969461&lat_max=51.01850632466553&lng_min=6.700286865234375&lng_max=7.215270996093751&action=getTankstellen ( see Chrome Dev Tools Network tab for detailed information )

then you might use ImportJSON to import data into your Google Sheet. https://workspace.google.com/marketplace/app/importjson_import_json_data_into_google/782573720506

Discovering hidden APIs using Chrome Dev Tools: https://www.youtube.com/watch?v=kPe3wtA9aPM

Anthony S
  • 124
  • 2