How can I get the HTML file of a Google Chrome website through bash?

51 Views Asked by At

I'm trying to write up a bash program that will display the full contents of this website (https://www.trivianerd.com/random-trivia-generator) and redirect it into a text file. I expect the content of the text file would look the same as if we were to open the Developer Tools in Inspect Element mode on the website above, in a browser.

Here is my code so far:

#!/bin/bash

# URL to fetch data from
url="https://www.trivianerd.com/random-trivia-generator"

output_file="trivia3.txt"
curl "$url" > "$output_file"

echo "Data fetched and saved to $output_file"

However, I'm not able to obtain the entire html file as displayed when I open the Developer Tools in Inspect Element mode. In particular, I couldn't locate any mentions of the question and the choices for the multiple choice question are within the html code that I retrieved through my function, but I was able to locate them when I opened the Developer Tools in Inspect Element mode.

Any suggestions on what I should do?

0

There are 0 best solutions below