Showing
7 changed files
with
70 additions
and
43 deletions
... | @@ -36,9 +36,6 @@ def login(driver): | ... | @@ -36,9 +36,6 @@ def login(driver): |
36 | 36 | ||
37 | 37 | ||
38 | def get_list(insta_id, driver): | 38 | def get_list(insta_id, driver): |
39 | - # get profile src | ||
40 | - src = driver.find_element_by_css_selector('.XjzKX .RR-M- span img').get_attribute('src') | ||
41 | - | ||
42 | # check followers | 39 | # check followers |
43 | followers_list = check_people(driver, "followers") | 40 | followers_list = check_people(driver, "followers") |
44 | 41 | ||
... | @@ -46,15 +43,10 @@ def get_list(insta_id, driver): | ... | @@ -46,15 +43,10 @@ def get_list(insta_id, driver): |
46 | driver.find_element_by_css_selector('.WaOAr .wpO6b').click() | 43 | driver.find_element_by_css_selector('.WaOAr .wpO6b').click() |
47 | time.sleep(1) | 44 | time.sleep(1) |
48 | 45 | ||
49 | - # check following | ||
50 | - following_list = check_people(driver, "following") | ||
51 | - | ||
52 | # update at firebase | 46 | # update at firebase |
53 | data = { | 47 | data = { |
54 | "followers": followers_list, | 48 | "followers": followers_list, |
55 | - "following": following_list, | ||
56 | "insta_id": insta_id, | 49 | "insta_id": insta_id, |
57 | - "src": src | ||
58 | } | 50 | } |
59 | update_data(insta_id, data) | 51 | update_data(insta_id, data) |
60 | 52 | ||
... | @@ -78,7 +70,7 @@ def crawler_instagram(insta_id): | ... | @@ -78,7 +70,7 @@ def crawler_instagram(insta_id): |
78 | driver.get(url=url) | 70 | driver.get(url=url) |
79 | time.sleep(2) | 71 | time.sleep(2) |
80 | 72 | ||
81 | - data = {}; | 73 | + data = {} |
82 | 74 | ||
83 | try: | 75 | try: |
84 | isPrivate = driver.find_element_by_class_name('rkEop').text | 76 | isPrivate = driver.find_element_by_class_name('rkEop').text | ... | ... |
... | @@ -3,23 +3,33 @@ import os | ... | @@ -3,23 +3,33 @@ import os |
3 | from config.key import DATABASE_ID, DATABASE_PW | 3 | from config.key import DATABASE_ID, DATABASE_PW |
4 | from config.URLs import DATABASE_URL | 4 | from config.URLs import DATABASE_URL |
5 | 5 | ||
6 | -os.putenv('NLS_LANG', '.UTF8') | ||
7 | - | ||
8 | 6 | ||
9 | def connectDB(): | 7 | def connectDB(): |
10 | connection = cx_Oracle.connect(DATABASE_ID, DATABASE_PW, DATABASE_URL) | 8 | connection = cx_Oracle.connect(DATABASE_ID, DATABASE_PW, DATABASE_URL) |
11 | 9 | ||
10 | + global cursor | ||
11 | + | ||
12 | cursor = connection.cursor() | 12 | cursor = connection.cursor() |
13 | + print('my') | ||
14 | + print(cursor) | ||
15 | + cursor.execute(""" | ||
16 | + select * from users where user_id=\'__tester__\' | ||
17 | + """) | ||
13 | 18 | ||
14 | - # cursor.execute(""" | 19 | + res = cursor.fetchall() |
15 | - # select name | 20 | + print(res) |
16 | - # from test_db | 21 | + print('my') |
17 | - # where text = :texting""", | ||
18 | - # texting="테스트" | ||
19 | - # ) | ||
20 | 22 | ||
21 | return cursor | 23 | return cursor |
22 | 24 | ||
23 | 25 | ||
24 | -def closeDB(cursor): | ||
25 | - cursor.close() | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
26 | +def closeDB(): | ||
27 | + cursor.close() | ||
28 | + | ||
29 | + | ||
30 | +def queryDB(query): | ||
31 | + cursor.execute(query) | ||
32 | + | ||
33 | + res = cursor.fetchall() | ||
34 | + | ||
35 | + return res | ... | ... |
router/__init__.py
0 → 100644
File mode changed
router/search.py
0 → 100644
1 | +from flask import jsonify, Response | ||
2 | +import json | ||
3 | +import cx_Oracle | ||
4 | +import os | ||
5 | +from config.key import DATABASE_ID, DATABASE_PW | ||
6 | +from config.URLs import DATABASE_URL | ||
7 | + | ||
8 | + | ||
9 | +def search(insta_id): | ||
10 | + connection = cx_Oracle.connect(DATABASE_ID, DATABASE_PW, DATABASE_URL) | ||
11 | + cursor = connection.cursor() | ||
12 | + | ||
13 | + query = """ | ||
14 | + select * from users where user_id=\'%s\' | ||
15 | + """ % insta_id | ||
16 | + | ||
17 | + cursor.execute(query) | ||
18 | + exist = cursor.fetchall() | ||
19 | + | ||
20 | + cursor.close() | ||
21 | + | ||
22 | + return Response(json.dumps(exist), mimetype='application/json') | ||
23 | + | ||
24 | + | ||
25 | +if __name__ == '__main__': | ||
26 | + os.putenv('NLS_LANG', '.UTF8') | ||
27 | + cx_Oracle.init_oracle_client(lib_dir="/Users/choewonseog/Downloads/instantclient_19_8") | ||
28 | + print(search('__tester2__').data) | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
router/update.py
0 → 100644
1 | +from crawler.crawler_instagram import crawler_instagram | ||
2 | +from flask import jsonify | ||
3 | + | ||
4 | + | ||
5 | +def update(insta_id): | ||
6 | + data = {} | ||
7 | + try: | ||
8 | + data = crawler_instagram(insta_id) | ||
9 | + except Exception as e: | ||
10 | + print(e) | ||
11 | + | ||
12 | + return jsonify(data) | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +import cx_Oracle | ||
1 | import os | 2 | import os |
2 | -from flask import Flask, render_template, request, jsonify, send_from_directory | 3 | +from flask import Flask, render_template, request, send_from_directory |
3 | -from crawler.crawler_instagram import crawler_instagram | 4 | +from database.connect import connectDB |
4 | -from config.firebase import get_data_by_id | ||
5 | 5 | ||
6 | +from router.update import update | ||
7 | +from router.search import search | ||
6 | 8 | ||
7 | root_dir = os.path.dirname(os.getcwd()) | 9 | root_dir = os.path.dirname(os.getcwd()) |
8 | my_path = os.path.join(root_dir, 'check-your-instagram', 'app', 'public') | 10 | my_path = os.path.join(root_dir, 'check-your-instagram', 'app', 'public') |
9 | app = Flask(__name__, static_folder=os.path.abspath(my_path)) | 11 | app = Flask(__name__, static_folder=os.path.abspath(my_path)) |
10 | 12 | ||
11 | - | 13 | +os.putenv('NLS_LANG', '.UTF8') |
12 | -def update(insta_id): | 14 | +cx_Oracle.init_oracle_client(lib_dir="/Users/choewonseog/Downloads/instantclient_19_8") |
13 | - data = {} | ||
14 | - try: | ||
15 | - data = crawler_instagram(insta_id) | ||
16 | - except Exception as e: | ||
17 | - print(e) | ||
18 | - | ||
19 | - return jsonify(data) | ||
20 | - | ||
21 | - | ||
22 | -def search(insta_id): | ||
23 | - result = {} | ||
24 | - try: | ||
25 | - result = get_data_by_id(insta_id) | ||
26 | - except Exception as e: | ||
27 | - print(e) | ||
28 | - | ||
29 | - return jsonify(result) | ||
30 | 15 | ||
31 | 16 | ||
32 | @app.errorhandler(404) | 17 | @app.errorhandler(404) |
... | @@ -51,4 +36,4 @@ if __name__ == "__main__": | ... | @@ -51,4 +36,4 @@ if __name__ == "__main__": |
51 | print(" server is start") | 36 | print(" server is start") |
52 | print("-" * 60) | 37 | print("-" * 60) |
53 | 38 | ||
54 | - app.run(host="localhost", port=8080, debug=True) | 39 | + app.run(host="localhost", port=5000, debug=True) | ... | ... |
-
Please register or login to post a comment