Search code examples
xpathgoogle-sheetsgoogle-sheets-formulagoogle-sheets-query

How do I xpath into the "main" section of a web page?


I'm trying to use the importxml function in google sheets to look at the ticket data on a StubHub event.

Below is the xpath provided by "inspect -> copy xpath" on the page but it doesn't work. I've playing around with the pathing for about an hour now and it seems to be held up on the "main" id... I can't seem to grab data under that header.

 *[@id="main"]/div/div/div[1]/div[2]/section[1]/div[1]/ul/div/li[1]

I published the workbook with the link and updated path here. I'm looking for the manifest of tickets (including row, price, etc.) to be listed in the workbook.

How do I get the xpath syntax to query into the "main" section?


Solution

  • Unfortunately, you won't get anything with Google Sheets since Javascript is needed to display the data. IMPORTFROMWEB addon which supports JS rendering also fails with this website. In my opinion, you have 3 options to achieve your goal :

    • Using Selenium + Python (or any other programming language)
    • Using Python with requests to get the JSON loaded in the background (credentials required (>Authorization header)), then filter it with json. The url of the JSON starts with : https://www.stubhub.com/bfx/api/search/inventory/v2/listings?
    • Do the same as the previous solution but with Google AppsScript directly from Google Sheets.