Showing
3 changed files
with
34 additions
and
10 deletions
... | @@ -48,7 +48,7 @@ def get_list(insta_id, driver): | ... | @@ -48,7 +48,7 @@ def get_list(insta_id, driver): |
48 | 48 | ||
49 | 49 | ||
50 | def crawler_instagram(insta_id): | 50 | def crawler_instagram(insta_id): |
51 | - driver = webdriver.Chrome(executable_path='./chromedriver') | 51 | + driver = webdriver.Chrome(executable_path='/Users/choewonseog/Documents/check-your-instagram/crawler/chromedriver') |
52 | driver.get(url=INSTAGRAM_URL) | 52 | driver.get(url=INSTAGRAM_URL) |
53 | time.sleep(4) | 53 | time.sleep(4) |
54 | 54 | ... | ... |
1 | import os | 1 | import os |
2 | -from flask import Flask, render_template, request | 2 | +from flask import Flask, render_template, request, jsonify |
3 | 3 | ||
4 | from crawler.crawler_instagram import crawler_instagram | 4 | from crawler.crawler_instagram import crawler_instagram |
5 | 5 | ||
... | @@ -16,12 +16,20 @@ def home(): | ... | @@ -16,12 +16,20 @@ def home(): |
16 | return render_template('index.html') | 16 | return render_template('index.html') |
17 | 17 | ||
18 | 18 | ||
19 | -@app.route("/update", methods=["POST"]) | 19 | +@app.route("/update", methods=["GET"]) |
20 | -def check(): | 20 | +def update(): |
21 | - insta_id = request.form['insta_id'] | 21 | + insta_id = request.args.get('insta_id') |
22 | - | ||
23 | crawler_instagram(insta_id) | 22 | crawler_instagram(insta_id) |
24 | 23 | ||
24 | + data = { | ||
25 | + "insta_id" : insta_id | ||
26 | + } | ||
27 | + return jsonify(data) | ||
28 | + | ||
29 | +@app.route("/hello", methods=["GET"]) | ||
30 | +def hello(): | ||
31 | + return "hello" | ||
32 | + | ||
25 | 33 | ||
26 | if __name__ == "__main__": | 34 | if __name__ == "__main__": |
27 | print("-" * 60) | 35 | print("-" * 60) | ... | ... |
... | @@ -5,9 +5,25 @@ | ... | @@ -5,9 +5,25 @@ |
5 | </head> | 5 | </head> |
6 | <body> | 6 | <body> |
7 | <h1>메인 화면</h1> | 7 | <h1>메인 화면</h1> |
8 | - <form action="/check" method="POST"> | 8 | + <input id="insta_id" placeholder="id" type="text" name="insta_id"/> |
9 | - <input id="insta_id" placeholder="id" type="text" name="insta_id"/> | 9 | + <button id="submit_id">제출</button> |
10 | - <button>제출</button> | 10 | + <script> |
11 | - </form> | 11 | + const button = document.querySelector('#submit_id') |
12 | + const input = document.querySelector('#insta_id') | ||
13 | + | ||
14 | + button.addEventListener('click',async () => { | ||
15 | + let result = null; | ||
16 | + | ||
17 | + try { | ||
18 | + result = await (await fetch('http://localhost:5000/update?insta_id=' + input.value)).json() | ||
19 | + } catch (e) { | ||
20 | + console.log(e) | ||
21 | + } finally { | ||
22 | + if(result) { | ||
23 | + console.log(result.insta_id) | ||
24 | + } | ||
25 | + } | ||
26 | + }) | ||
27 | + </script> | ||
12 | </body> | 28 | </body> |
13 | </html> | 29 | </html> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment