Yes, you absolutely can! Google Sheets has a powerful function called IMPORTXML that can scrape data from websites. HowLongToBeat.com is generally pretty structured, so this can work well.
Important Considerations before we start:
Website Structure:IMPORTXML relies on the website's HTML structure. If HowLongToBeat.com changes its layout, the formulas might break.
Rate Limiting: If you have hundreds of games and try to refresh all the data at once, HLTB (or Google Sheets) might temporarily block your requests. It's usually fine for a reasonable list.
Ambiguity:IMPORTXML will go to the first search result HowLongToBeat returns for your game name. If your game name is very generic (e.g., "The Game"), it might not get the correct one. Being specific helps.
Dynamic Content:IMPORTXML can't execute JavaScript. Most of HLTB's time data is loaded with the initial page, so this isn't a problem, but it's good to be aware of.
Method: Using IMPORTXML in Google Sheets
This method involves constructing a URL for the HLTB search and then using XPath to find the specific time values on the resulting page.
Let's assume your game titles are in Column A, starting from cell A2.
Step 1: Set up your Sheet
Create a new Google Sheet.
In A1, put "Game Title".
In B1, put "HLTB Main Story".
In C1, put "HLTB Main + Extras".
In D1, put "HLTB Completionist".
List your game titles starting from A2.
Step 2: The IMPORTXML Formulas
We'll use HLTB's direct search URL: https://howlongtobeat.com/search?q=YOUR+GAME+NAME. This URL often redirects directly to the game's page if there's a strong match, which makes scraping easier.
Formula for "HLTB Main Story" (in cell B2):
excel
=IFERROR(IMPORTXML(CONCATENATE("https://howlongtobeat.com/search?q=", ENCODEURL(A2)), "//div[@class='game_time_label' and text()='Main Story']/following-sibling::div[@class='game_time']"), "N/A")
Explanation:
IFERROR(..., "N/A"): This wraps the entire formula. If IMPORTXML fails to find the data (e.g., game not found, website structure changed), it will display "N/A" instead of a #N/A error.
ENCODEURL(A2): Takes the game title from A2 (e.g., "Hollow Knight") and converts it into a URL-friendly format ("Hollow%20Knight").
"//div[@class='game_time_label' and text()='Main Story']/following-sibling::div[@class='game_time']": This is the XPath query.
//div: Looks for any div element anywhere on the page.
[@class='game_time_label' and text()='Main Story']: Specifically targets a div that has the class game_time_label AND whose text content is exactly "Main Story". This identifies the label for the Main Story time.
/following-sibling::div[@class='game_time']: From that identified label div, it looks for its next siblingdiv that has the class game_time. This is where the actual time value (e.g., "26h") is located on HLTB.
Formula for "HLTB Main + Extras" (in cell C2):
excel
=IFERROR(IMPORTXML(CONCATENATE("https://howlongtobeat.com/search?q=", ENCODEURL(A2)), "//div[@class='game_time_label' and text()='Main + Extras']/following-sibling::div[@class='game_time']"), "N/A")
(Only change is text()='Main + Extras')
Formula for "HLTB Completionist" (in cell D2):
excel
=IFERROR(IMPORTXML(CONCATENATE("https://howlongtobeat.com/search?q=", ENCODEURL(A2)), "//div[@class='game_time_label' and text()='Completionist']/following-sibling::div[@class='game_time']"), "N/A")
(Only change is text()='Completionist')
Step 3: Drag Down the Formulas
Enter the formulas in cells B2, C2, and D2.
Select all three cells (B2:D2).
Click and drag the small blue square at the bottom-right corner of the selection down to the last row where you have game titles. This will automatically apply the formulas to all your games.
Example in Action:
Game Title
HLTB Main Story
HLTB Main + Extras
HLTB Completionist
Hollow Knight
26h
40h
57h
The Witcher 3: Wild Hunt
51h
102h
170h
Elden Ring
58h
98h
132h
Cyberpunk 2077
24h
60h
106h
Portal 2
8h
10h
13h
(non-existent game)
N/A
N/A
N/A
This setup should give you a good automated way to pull the HLTB times directly into your Google Sheet!