0

I am making a basic web scraping app that dumps the results of the scraping into a JSON file. I want to display the scraping results in a table on an HTML page of the app. I am using json2html python library to convert JSON into an HTML table, but I don't know how to render the actual result res_2 into the web page. Below the python code and the HTML where I would like to table with the results to be. I am required to use a JSON structure and not a database here.

def dashboard():
    try:
        with open("message.json", "r") as r_file:
            res_1 = json.load(r_file)

        res_2 = json2html.convert(json = res_1)
        print("this is the results: ", res_2)

        return render_template('dashboard.html',tasks=res_2)

the div of the webpage on which I want to render the results res_2 is the following:

<div class="starter-template">

    {{tasks}}
    
    <strong id="emailHelp" class="form-text text-muted">If you do not see any results, please refresh the page!!</strong>
</div>

The result is that the table is not showing in the dashboard page, only the HTML code as following:

<table border="1"><tr><th>date</th><td>24-Jan-2021 (19:04:32.003751)</td></tr><tr><th>url</th>```<td>http://mrbacco.com</td></tr><tr><th>response code</th><td>200</td></tr><tr><th>title name</th><td>title</td></tr><tr><th>title</th><td>&lt;title&gt;[ mrbacco ] – [ Just another human on the internet ]&lt;/title&gt;</td></tr><tr><th>paragraphs</th><td>... 

I know I am doing something wrong: but I do not know what. Do I have to use a javascript function to call taskson the webpage? Any idea?

mrb
  • 39
  • 8

0 Answers0