Toggle navigation
Toggle navigation
This project
Loading...
Sign in
문채연
/
OSS_termproject
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Issues
0
Network
Create a new issue
Commits
Issue Boards
Authored by
MoonChaeyeon
2020-06-16 00:42:44 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ded98825a7534bcfba21057673b2d3c18abedac9
ded98825
1 parent
c8c22222
naver image crawling program
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
naver_image.py
naver_image_crawling.py
naver_image.py
0 → 100644
View file @
ded9882
from
urllib.request
import
urlopen
from
bs4
import
BeautifulSoup
as
bs
from
urllib.parse
import
quote_plus
baseUrl
=
'https://search.naver.com/search.naver?where=image&sm=tab_jum&query='
plusUrl
=
input
(
'검색어를 입력하세요 : '
)
# 한글 검색 자동 변환
url
=
baseUrl
+
quote_plus
(
plusUrl
)
html
=
urlopen
(
url
)
soup
=
bs
(
html
,
"html.parser"
)
img
=
soup
.
find_all
(
class_
=
'_img'
,
limit
=
20
)
n
=
1
for
i
in
img
:
imgUrl
=
i
[
'data-source'
]
with
urlopen
(
imgUrl
)
as
f
:
with
open
(
'사진'
+
plusUrl
+
str
(
n
)
+
'.jpg'
,
'wb'
)
as
h
:
# w - write b - binary
img
=
f
.
read
()
h
.
write
(
img
)
n
+=
1
print
(
'다운로드 완료'
)
\ No newline at end of file
naver_image_crawling.py
0 → 100644
View file @
ded9882
from
urllib.request
import
urlopen
from
bs4
import
BeautifulSoup
as
bs
from
urllib.parse
import
quote_plus
baseUrl
=
'https://search.naver.com/search.naver?where=image&sm=tab_jum&query='
plusUrl
=
input
(
'검색어를 입력하세요 : '
)
# 한글 검색 자동 변환
url
=
baseUrl
+
quote_plus
(
plusUrl
)
html
=
urlopen
(
url
)
soup
=
bs
(
html
,
"html.parser"
)
img
=
soup
.
find_all
(
class_
=
'_img'
,
limit
=
20
)
n
=
1
for
i
in
img
:
imgUrl
=
i
[
'data-source'
]
with
urlopen
(
imgUrl
)
as
f
:
with
open
(
'사진'
+
plusUrl
+
str
(
n
)
+
'.jpg'
,
'wb'
)
as
h
:
# w - write b - binary
img
=
f
.
read
()
h
.
write
(
img
)
n
+=
1
print
(
'다운로드 완료'
)
\ No newline at end of file
Please
register
or
login
to post a comment