-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathflask_backed_run.py
68 lines (45 loc) · 1.62 KB
/
flask_backed_run.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
64
65
66
67
68
import json
from typing import Dict
from flask import Flask, request, abort
from config import HOST, PORT
from scrapers.scraper_manager import ScraperManager
app = Flask(__name__)
def launchScrapingProcess(credentials: json, mode: str) -> Dict:
scraped_data = {}
if mode == '/social_scraping':
scraped_data.update(
ScraperManager.scrapeSocialNetworks(credentials=credentials)
)
elif mode == 'osint_scraping':
scraped_data.update(
ScraperManager.scrapeOSINTSites(credentials=credentials)
)
else:
scraped_data.update(
ScraperManager.scrapeSocialNetworks(credentials=credentials)
)
scraped_data.update(
ScraperManager.scrapeOSINTSites(credentials=credentials)
)
return scraped_data
@app.route('/', methods=['GET', 'POST'])
@app.route('/index', methods=['GET', 'POST'])
def indexPage():
return {}
@app.route('/full_scraping', methods=['POST'])
def launchFullScraping():
if request.method == 'POST':
return launchScrapingProcess(credentials=request.get_json(), mode='full_scraping')
abort(405)
@app.route('/social_scraping', methods=['POST'])
def launchSocialScraping():
if request.method == 'POST':
return launchScrapingProcess(credentials=request.get_json(), mode='social_scraping')
abort(405)
@app.route('/osint_scraping', methods=['POST'])
def launchOsintScraping():
if request.method == 'POST':
return launchScrapingProcess(credentials=request.get_json(), mode='osint_scraping')
abort(405)
if __name__ == "__main__":
app.run(host=HOST, port=PORT)