Skip to content

Commit

Permalink
#2 assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
gnchoco97 committed Mar 24, 2019
1 parent 5b22b31 commit 46ecb51
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 0 deletions.
8 changes: 8 additions & 0 deletions 2주차/박가나/01_bs4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import bs4

html_str = "<html><div></div></html>"
bsObj = bs4.BeautifulSoup(html_str, "html.parser")

print(type(bsObj))
print(bsObj)
print(bsObj.find("div"))
6 changes: 6 additions & 0 deletions 2주차/박가나/02_urlopen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import urllib.request

url = "https://www.naver.com"
html = urllib.request.urlopen(url)

print(html.read())
15 changes: 15 additions & 0 deletions 2주차/박가나/03_naver_parsing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import urllib.request
import bs4

url = "https://www.naver.com"
html = urllib.request.urlopen(url)

bsObj = bs4.BeautifulSoup(html, "html.parser")

# print(html.read())
# print(bsObj)

top_right = bsObj.find("div", {"class" : "area_links"})
first_a = top_right.find("a")

print(first_a.text)
16 changes: 16 additions & 0 deletions 2주차/박가나/04_naver_menu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import urllib.request
import bs4

url = "https://www.naver.com"
html = urllib.request.urlopen(url)

bsObj = bs4.BeautifulSoup(html, "html.parser")

ul = bsObj.find("ul", {"class" : "an_l"})

lis = ul.findAll("li")

for li in lis :
a_tag = li.find("a")
span = a_tag.find("span",{"class" : "an_txt"})
print(span.text)
15 changes: 15 additions & 0 deletions 2주차/박가나/05_naver_news.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from urllib.request import urlopen
import bs4

url = "http://news.naver.com"
html = urlopen(url)

bsObj = bs4.BeautifulSoup(html, "html.parser")

ul = bsObj.find("ul", {"id" : "text_today_main_news_801001"})

lis = ul.findAll("li")

for li in lis :
strong = li.find("strong")
print(strong.text)
15 changes: 15 additions & 0 deletions 2주차/박가나/assignment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import urllib.request
import bs4

url = "https://comic.naver.com/index.nhn"
html = urllib.request.urlopen(url)

bsObj = bs4.BeautifulSoup(html, "html.parser")

div = bsObj.find("div", {"class" : "tab_gr"})

lis = div.findAll("li")

for li in lis :
a_tag = li.find("a")
print(a_tag.text)
Binary file added 2주차/박가나/cmd창.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2주차/박가나/인터넷창.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 46ecb51

Please sign in to comment.