Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from bs4 import BeautifulSoup
- import requests
- import urllib.request
- base_url = 'https://news.naver.com/main/main.nhn?mode=LSD&mid=shm&sid1='
- category = [100]
- for i in category:
- URL = base_url + str(i)
- response = urllib.request.urlopen(URL)
- soup = BeautifulSoup(response, "html.parser")
- #results = soup.select("#section_body .photo a")
- results = soup.select("#section_body > ul.type06_headline > li:nth-child(1) > dl > dt:nth-child(2) > a")
- print(results)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement