-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
42 lines (38 loc) · 1.06 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
from incruit import get_whole_jobs as get_incruit_jobs
from flask import Flask, render_template, request, redirect, send_file
from save import save_to_file
app = Flask("SuperScrapper")
db = {}
@app.route("/")
def home():
return render_template("potato.html")
@app.route("/report")
def report():
word = request.args.get('word')
if word:
word = word.lower()
existingJobs = db.get(word)
if existingJobs:
jobs = existingJobs
else:
jobs = get_incruit_jobs(word)
db[word] = jobs
else:
redirect("/")
return render_template("report.html",searchingBy=word,
resultsNumber=len(jobs),jobs=jobs)
@app.route("/export")
def export():
try:
word = request.args.get('word')
if not word:
raise Exception()
word = word.lower()
jobs = db.get(word)
if not jobs:
raise Exception()
save_to_file(jobs)
return send_file("jobs.csv")
except:
return redirect("/")
app.run(host="127.0.0.1")