Toggle navigation
Toggle navigation
This project
Loading...
Sign in
최원석
/
2021-1-database-project
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
1seok2
2021-03-07 21:30:14 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b8f1f0ea6b5b7f81986650b06328e1f22b59020f
b8f1f0ea
1 parent
8ac1b0d3
get result
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
10 deletions
crawler/crawler_instagram.py
server.py
templates/index.html
crawler/crawler_instagram.py
View file @
b8f1f0e
...
...
@@ -48,7 +48,7 @@ def get_list(insta_id, driver):
def
crawler_instagram
(
insta_id
):
driver
=
webdriver
.
Chrome
(
executable_path
=
'
.
/chromedriver'
)
driver
=
webdriver
.
Chrome
(
executable_path
=
'
/Users/choewonseog/Documents/check-your-instagram/crawler
/chromedriver'
)
driver
.
get
(
url
=
INSTAGRAM_URL
)
time
.
sleep
(
4
)
...
...
server.py
View file @
b8f1f0e
import
os
from
flask
import
Flask
,
render_template
,
request
from
flask
import
Flask
,
render_template
,
request
,
jsonify
from
crawler.crawler_instagram
import
crawler_instagram
...
...
@@ -16,12 +16,20 @@ def home():
return
render_template
(
'index.html'
)
@app.route
(
"/update"
,
methods
=
[
"POST"
])
def
check
():
insta_id
=
request
.
form
[
'insta_id'
]
@app.route
(
"/update"
,
methods
=
[
"GET"
])
def
update
():
insta_id
=
request
.
args
.
get
(
'insta_id'
)
crawler_instagram
(
insta_id
)
data
=
{
"insta_id"
:
insta_id
}
return
jsonify
(
data
)
@app.route
(
"/hello"
,
methods
=
[
"GET"
])
def
hello
():
return
"hello"
if
__name__
==
"__main__"
:
print
(
"-"
*
60
)
...
...
templates/index.html
View file @
b8f1f0e
...
...
@@ -5,9 +5,25 @@
</head>
<body>
<h1>
메인 화면
</h1>
<form
action=
"/check"
method=
"POST"
>
<input
id=
"insta_id"
placeholder=
"id"
type=
"text"
name=
"insta_id"
/>
<button>
제출
</button>
</form>
<input
id=
"insta_id"
placeholder=
"id"
type=
"text"
name=
"insta_id"
/>
<button
id=
"submit_id"
>
제출
</button>
<script>
const
button
=
document
.
querySelector
(
'#submit_id'
)
const
input
=
document
.
querySelector
(
'#insta_id'
)
button
.
addEventListener
(
'click'
,
async
()
=>
{
let
result
=
null
;
try
{
result
=
await
(
await
fetch
(
'http://localhost:5000/update?insta_id='
+
input
.
value
)).
json
()
}
catch
(
e
)
{
console
.
log
(
e
)
}
finally
{
if
(
result
)
{
console
.
log
(
result
.
insta_id
)
}
}
})
</script>
</body>
</html>
\ No newline at end of file
...
...
Please
register
or
login
to post a comment