From ad611a2f197fa758a743f61f3b95f7abfd278577 Mon Sep 17 00:00:00 2001 From: kim_yubin Date: Fri, 23 Nov 2018 20:04:08 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B6=94=EA=B0=80=20'=EB=84=A4=EC=9D=B4?= =?UTF-8?q?=EB=B2=84=20=ED=81=AC=EB=A1=A4=EB=A7=81'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 네이버 크롤링 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 네이버 크롤링 diff --git a/네이버 크롤링 b/네이버 크롤링 new file mode 100644 index 0000000..a3e2e28 --- /dev/null +++ b/네이버 크롤링 @@ -0,0 +1,24 @@ +import requests +from bs4 import BeautifulSoup + +response = requests.get('https://www.naver.com/') +html = response.text +soup = BeautifulSoup(html, 'html.parser') +check=[] +ranking=1 + +for tag in soup.select('li[class=ah_item] a'): + + url = tag.get('href') + + if tag.get('data-ssl'): + print('\n' + "* " * 20 + '\n') + print(url) + + related = requests.get(url) + htmlr = related.text + soupr = BeautifulSoup(htmlr, 'html.parser') + + for tagr in soupr.select('ul[class=_related_keyword_ul] a'): + result = tagr.text + print(result) \ No newline at end of file