Advertisement
Guest User

crawler

a guest
Apr 5th, 2020
576
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. import sys
  2. from bs4 import BeautifulSoup
  3. import requests
  4. import urllib.request
  5.  
  6. base_url = 'https://news.naver.com/main/main.nhn?mode=LSD&mid=shm&sid1='
  7. category = [100]
  8.  
  9. for i in category:
  10.     URL = base_url + str(i)
  11.     response = urllib.request.urlopen(URL)
  12.     soup = BeautifulSoup(response, "html.parser")
  13.     #results = soup.select("#section_body .photo a")
  14.     results = soup.select("#section_body > ul.type06_headline > li:nth-child(1) > dl > dt:nth-child(2) > a")
  15.     print(results)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement