I'm working on a Flask app where I'm webscraping from multiple URLs (wide range, can be over 100). It works locally, but when deployed to Heroku, it times out.
This is a snippet of the code I'm using, where the bookOutletHas() function is the function that does the webscraping using requests and BeautifulSoup.
for book in gr_books:
temp_book = book.book
title = temp_book["title"]
author = temp_book["authors"]["author"]["name"]
arr = bookOutletHas(title=title, author=author)
if arr[0]:
valid_books += [ str(arr[1]) ]
return render_template("main_page.html",books=valid_books)
My first instinct was to find a way to code it so that it updates the page every time the valid_books array is updated (like rendering the template again each time?) but I'm unsure how to approach this. I don't have any knowledge of javascript so, if possible, I'm seeking an approach through Python and HTML.