인프런 - 강의/청와대 청원 데이터 시각화

4 - 국민 청원 페이지 여러개 수집

----___<<<<< 2020. 3. 1. 18:47

from bs4 import BeautifulSoup
from selenium import webdriver
import time

driver = webdriver.Chrome("./chromedriver")

for i in range(1,11) :

    driver.get("https://www1.president.go.kr/petitions/best?page=" + str(i))

    soup = BeautifulSoup(driver.page_source, 'html.parser')

    result_list = []

    for i in soup.select("#cont_view > div.cs_area > div > div > div.board.text > div.b_list.category > div.bl_body > ul > li"):
        print(i.find("div", class_="bl_subject").text[3:].strip())
        result_list.append(i.find("div", class_="bl_subject").text[3:])

    time.sleep(5)

driver.close()