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-11 23:29:02 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
af44dcf8e6906b077eaa78ff2ed82ea987abec9c
af44dcf8
1 parent
083ddc9d
add profile img crawling
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
39 additions
and
27 deletions
app/src/App.ts
app/src/assets/style/Footer.scss
app/src/components/addEvent.ts
app/src/store/index.ts
app/src/store/state.ts
app/src/views/body/contents/main/Main.ts
crawler/crawler_instagram.py
app/src/App.ts
View file @
af44dcf
...
...
@@ -10,13 +10,17 @@ import Header from "./views/header";
import
Body
from
"./views/body"
;
import
Footer
from
"./views/footer"
;
import
'./assets/style/App.scss'
;
import
{
getState
}
from
"@src/store/state"
;
const
App
=
(
pathname
:
string
)
:
string
=>
{
/* id 없을 시 id 입력으로 redirect */
if
(
!
getState
().
insta_id
)
pathname
=
''
;
history
.
pushState
(
''
,
''
,
pathname
);
return
`
<div class="container">
${
Header
()}
${
pathname
&&
Header
()}
${
Body
(
pathname
)}
</div>
${
Footer
()}
...
...
app/src/assets/style/Footer.scss
View file @
af44dcf
.footer
{
height
:
120px
;
background-color
:
#
afafaf
;
background-color
:
#
f3f3f3
;
display
:
flex
;
justify-content
:
center
;
align-items
:
center
;
font-size
:
.8rem
;
width
:
100%
;
color
:
#
fafaf
a
;
color
:
#
aaaaa
a
;
}
\ No newline at end of file
...
...
app/src/components/addEvent.ts
View file @
af44dcf
...
...
@@ -6,7 +6,7 @@
import
{
BASE_URL
}
from
"@src/config/url"
;
import
{
randomTransition
}
from
"@src/components/pageTransition"
;
import
{
getState
,
setState
}
from
"@src/store/state"
;
import
{
setState
}
from
"@src/store/state"
;
export
const
addEvent
=
async
(
e
:
Event
,
...
...
@@ -38,11 +38,7 @@ export const addEvent = async (
console
.
log
(
'res!'
,
result
);
result
&&
$App
&&
(()
=>
{
randomTransition
();
setState
({
insta_id
:
insta_id
,
followers
:
result
.
followers
,
following
:
result
.
following
});
setState
(
result
);
setTimeout
(()
=>
{
$App
.
innerHTML
=
App
(
'main'
);
},
1200
)
...
...
@@ -66,11 +62,7 @@ export const addEvent = async (
console
.
log
(
result
);
result
&&
$App
&&
(()
=>
{
randomTransition
();
setState
({
insta_id
:
insta_id
,
followers
:
result
.
followers
,
following
:
result
.
following
});
setState
(
result
);
setTimeout
(()
=>
{
$App
.
innerHTML
=
App
(
'main'
);
},
1200
)
...
...
app/src/store/index.ts
deleted
100644 → 0
View file @
083ddc9
export
{
default
}
from
'./state'
;
app/src/store/state.ts
View file @
af44dcf
...
...
@@ -8,13 +8,15 @@
export
interface
StateType
{
insta_id
?
:
string
,
followers
?
:
Array
<
string
>
,
following
?
:
Array
<
string
>
following
?
:
Array
<
string
>
,
src
?
:
string
}
const
initialState
=
{
insta_id
:
''
,
followers
:
[
''
],
following
:
[
''
],
src
:
''
,
}
let
state
:
StateType
=
initialState
;
...
...
@@ -28,5 +30,3 @@ export const setState = (newState: StateType): void => {
export
const
getState
=
()
=>
{
return
state
}
\ No newline at end of file
export
default
state
;
...
...
app/src/views/body/contents/main/Main.ts
View file @
af44dcf
...
...
@@ -5,20 +5,33 @@
* 업데이트하기
* 다른 메뉴 보기
**/
import
state
from
"@src/store"
;
import
{
getState
}
from
"@src/store/state"
;
const
Main
=
()
=>
{
let
contents
=
`<div>
${
state
.
insta_id
}
</div>`
contents
+=
getState
().
followers
?.
map
(
id
=>
`<div>followers
${
id
}
</div>`
)
contents
+=
getState
().
following
?.
map
(
id
=>
`<div>following
${
id
}
</div>`
)
const
state
=
getState
();
let
followers
:
string
=
''
;
let
following
:
string
=
''
;
state
.
followers
?.
forEach
(
id
=>
{
followers
+=
`<div>
${
id
}
</div>`
});
state
.
following
?.
forEach
(
id
=>
{
following
+=
`<div>
${
id
}
</div>`
});
return
`
<div class="main">
its main
${
contents
}
<div id="profile">
<img src="
${
state
.
src
}
" alt="
${
state
.
insta_id
}
-image"/>
<span class="profile-id">
${
state
.
insta_id
}
</span>
</div>
<div id="list">
<div id="followers">
${
followers
}
</div>
<div id="following">
${
following
}
</div>
</div>
</div>
`
}
...
...
crawler/crawler_instagram.py
View file @
af44dcf
...
...
@@ -35,6 +35,9 @@ def login(driver):
def
get_list
(
insta_id
,
driver
):
# get profile src
src
=
driver
.
find_element_by_css_selector
(
'.XjzKX .RR-M- span img'
)
.
get_attribute
(
'src'
)
# check followers
followers_list
=
check_people
(
driver
,
"followers"
)
...
...
@@ -49,7 +52,8 @@ def get_list(insta_id, driver):
data
=
{
"followers"
:
followers_list
,
"following"
:
following_list
,
"insta_id"
:
insta_id
"insta_id"
:
insta_id
,
"src"
:
src
}
update_data
(
insta_id
,
data
)
...
...
Please
register
or
login
to post a comment