๊ณผ์ ๋ต์์ ๋ณด์ง์๊ณ ์ค์ค๋ก ๊ตฌ๊ธ๋งํด์ ๋ง๋ ์น ํฌ๋กค๋ง ํ๋ก๊ทธ๋จ(10ํ์ด์ง ๋จ์) ์ฝ๋์
๋๋ค.
import requests from bs4 import BeautifulSoup import pyautogui keyword = pyautogui.prompt("๊ฒ์์ด๋ฅผ ์
๋ ฅํ์ธ์>>>") lastpage = pyautogui.prompt("๋ง์ง๋ง ํ์ด์ง ๋ฒํธ๋ฅผ ์
๋ ฅํด ์ฃผ์ธ์") pageNum = 1 for i in range(1,int(lastpage)*10,10): print(f"{pageNum}ํ์ด์ง ์
๋๋ค.=====================") response= requests.get(f"https://search.naver.com/search.naver?ssc=tab.news.all&where=news&sm=tab_jum&query={keyword}&start={i}") html = response.text soup = BeautifulSoup(html, 'html.parser') links = soup.select(".news_tit") for link in links: title = link.text url = link.attrs['href'] print(title,url) pageNum = pageNum+1์์ ๊ฐ์ด ์ฝ๋๋ฅผ ์คํ์ํค๋, ์ ๋ 10ํ์ด์ง๊น์ง ํฌ๋กค๋งํ๊ณ ์ถ์๋ฐ 1,11,21,31---91ํ์ด์ง ์ด๋ฐ์์ผ๋ก ๊ฐ์ ธ์์ง๋๋ค. ๋ญ๊ฐ ๋ฌธ์ ์ผ๊น์?