-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
63 lines (42 loc) · 1.48 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Flask
from flask import Flask, render_template, redirect
# App
from app import create_app
from app.forms import SearchForm
# Scrappers
from app.scrapers import LinioSpider, FalabellaSpider, AmazonSpider, FalabellaSpider, run_spider2
app = create_app()
@app.route('/', methods=['GET','POST'])
def index():
"""
This function controls the flow of requests to the index
Returns:
[redirect] -- [Redirects to page when form is filled correctly]
[render_template] -- [It is in charge of rendering the index passing the context parameters]
"""
search_form = SearchForm()
context = {
'search_form': search_form,
}
if search_form.validate_on_submit():
search = search_form.search.data
linio_spider = LinioSpider(search)
linio_products = linio_spider.scrape()
context['linio_products'] = linio_products
amazon_spider = AmazonSpider(search)
amazon_products = amazon_spider.scrape()
context['amazon_products'] = amazon_products
falabella_spider = FalabellaSpider(search)
falabella_products = falabella_spider.scrape()
context['falabella_products'] = falabella_products
return render_template('index.html', **context)
return render_template('index.html', **context)
@app.route('/mugs-scrapper')
def mugs_scrapper():
"""[summary]
Returns:
[type] -- [description]
"""
return "Mugs Scrapper"
if __name__ == '__main__':
app.run()