Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김건
/
Comment_Analysis
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
김건
2019-11-17 02:33:02 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
cbcbb8eac17e34b66cb2051959d60d78bfec116b
cbcbb8ea
1 parent
2e81d7d8
2차 추가 개발사항. Input value를 video_id만 입력하는 것에서 video url을 전체 입력할 수 있도록 변경
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
2 deletions
Youtube/downloader.py
Youtube/main.py
Youtube/downloader.py
View file @
cbcbb8e
...
...
@@ -9,7 +9,7 @@ import requests
import
argparse
import
lxml.html
import
io
from
urllib.parse
import
urlparse
,
parse_qs
from
lxml.cssselect
import
CSSSelector
YOUTUBE_COMMENTS_URL
=
'https://www.youtube.com/all_comments?v={youtube_id}'
...
...
@@ -130,6 +130,23 @@ def goto_Menu(result_List) :
else
:
print
(
'Not Found'
)
## input video 값 parsing
def
video_id
(
value
):
query
=
urlparse
(
value
)
if
query
.
hostname
==
'youtu.be'
:
return
query
.
path
[
1
:]
if
query
.
hostname
in
(
'www.youtube.com'
,
'youtube.com'
):
if
query
.
path
==
'/watch'
:
p
=
parse_qs
(
query
.
query
)
return
p
[
'v'
][
0
]
if
query
.
path
[:
7
]
==
'/embed/'
:
return
query
.
path
.
split
(
'/'
)[
2
]
if
query
.
path
[:
3
]
==
'/v/'
:
return
query
.
path
.
split
(
'/'
)[
2
]
# fail?
return
None
def
main
():
#parser = argparse.ArgumentParser(add_help=False, description=('Download Youtube comments without using the Youtube API'))
...
...
@@ -138,6 +155,8 @@ def main():
#parser.add_argument('--output', '-o', help='Output filename (output format is line delimited JSON)')
#parser.add_argument('--limit', '-l', type=int, help='Limit the number of comments')
Youtube_id1
=
input
(
'Youtube_ID 입력 :'
)
## Cutting Link를 받고 id만 딸 수 있도록
Youtube_id1
=
video_id
(
Youtube_id1
)
Output1
=
input
(
'결과를 받을 파일 입력 :'
)
Limit1
=
input
(
'제한 갯수 입력 : '
)
##### argument로 받지 않고 input으로 받기 위한 것
...
...
@@ -186,7 +205,8 @@ def main():
if
limit
and
count
>=
limit
:
break
print
(
'
\n
Done!'
)
goto_Menu
(
result_List
)
return
result_List
#goto_Menu(result_List)
...
...
Youtube/main.py
0 → 100644
View file @
cbcbb8e
import
downloader
from
scraper
import
scrape_url
from
time
import
sleep
from
urllib.parse
import
urlparse
def
call_main
():
print
(
' Comment Thread 생성중
\n
'
)
sleep
(
1
)
print
(
' **************************************************************'
)
print
(
' **************************************************************'
)
print
(
' **************************************************************'
)
print
(
' **************** 생성 완료 정보를 입력하세요. **************** '
)
print
(
' **************************************************************'
)
print
(
' **************************************************************'
)
print
(
' **************************************************************'
)
a
=
downloader
.
main
()
return
a
CommentList
=
call_main
()
Please
register
or
login
to post a comment