728x90
반응형
검색 결과 페이지에 출력하기(grid 사용)
server.py
@app.route("/report")
def report():
word = request.args.get("word")
if word:
word = word.lower()
existingNews = db.get(word)
if existingNews:
news = existingNews
else:
news = get_news(word)
db[word] = news
else:
return redirect("/")
return render_template(
"report.html",
searchingBy=word,
resultNumber=len(news),
news=news
)
report.html
<div class="about--banner">
<h2>result</h2>
<h3>Found {{resultNumber}} results for: {{searchingBy}}</h3>
<section>
<h4>Title</h4>
<h4>Company</h4>
<h4>Date</h4>
<h4>Link</h4>
{% for result_news in news%}
<span>{{result_news.title}}</span>
<span>{{result_news.company}}</span>
<span>{{result_news.date}}</span>
<a href="{{result_news.link}}" target="_blank">Go to page</a>
{% endfor %}
</section>
</div>
반응형
'프로그래밍 > Flask' 카테고리의 다른 글
ajax 사용하기(json data 보내고 받기) (0) | 2021.01.04 |
---|---|
Web Scraping9(CSV파일에 저장하고 다운로드) (0) | 2021.01.01 |
html include 하기 (0) | 2020.12.31 |
net:: err_aborted 404 (not found) (0) | 2020.12.31 |
Web Scraping7(fakeDB 생성) (0) | 2020.12.31 |