Skip to content

Instantly share code, notes, and snippets.

@askcompany-kr
Created November 12, 2019 07:07
Show Gist options
  • Select an option

  • Save askcompany-kr/a7a64bb2b6d43aa866e09d08fac8e0dc to your computer and use it in GitHub Desktop.

Select an option

Save askcompany-kr/a7a64bb2b6d43aa866e09d08fac8e0dc to your computer and use it in GitHub Desktop.
import requests
from bs4 import BeautifulSoup
res = requests.get("http://naver.com")
html = res.text
soup = BeautifulSoup(html, 'html.parser')
tag_list = soup.select('.PM_CL_realtimeKeyword_rolling .ah_k')
for rank, tag in enumerate(tag_list, 1): # 항상 하위 block 전에 콤마(:)를 씁니다.
label = tag.text
print('{}: {}'.format(rank, label))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment