추가 '네이버 크롤링'

This commit is contained in:
kim_yubin 2018-11-23 20:04:08 +09:00
parent 6ccc22f2cb
commit ad611a2f19
1 changed files with 24 additions and 0 deletions

24
네이버 크롤링 Normal file
View File

@ -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)