yubin_repository/네이버 크롤링

24 lines
585 B
Plaintext

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)