Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from bs4 import BeautifulSoup
- import requests
- base_url = 'https://news.naver.com/main/main.nhn?mode=LSD&mid=shm&sid1='
- category = [100, 101, 102, 103, 104, 105] #정치, 경제, 사회, 생활문화, 세계, 생활과학
- category = [100]
- for i in category:
- URL = base_url + str(i)
- response = requests.get(URL)
- soup = BeautifulSoup(response.text, "html.parser")
- results = soup.select(".section_list_ranking li a")
- for idx, tag in enumerate(results):
- print(f"{idx:>02} : {tag.text}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement