Skip to content

Instantly share code, notes, and snippets.

@allieus
Created January 22, 2019 03:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allieus/c9b24924b6799a7e0d187de6507b76a0 to your computer and use it in GitHub Desktop.
Save allieus/c9b24924b6799a7e0d187de6507b76a0 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