Skip to content

Commit

Permalink
[Scrap] 광주시의회 스크랩
Browse files Browse the repository at this point in the history
  • Loading branch information
pingpingy1 committed Nov 8, 2023
1 parent 01478e3 commit ac71f41
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions scrap/metropolitan_council.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from urllib.parse import urlparse

from scrap.utils.types import CouncilType, Councilor, ScrapResult
from scrap.utils.requests import get_soup
from scrap.utils.requests import get_soup, get_selenium, By


def scrap_metro_1(
Expand Down Expand Up @@ -139,10 +139,17 @@ def scrap_metro_5(url="https://council.gwangju.go.kr/index.do?PID=029") -> Scrap
:return: 의원들의 이름과 정당 데이터를 담은 ScrapResult 객체
"""

soup = get_soup(url, verify=False).find("table", class_="data").find("tbody")
councilors: list[Councilor] = []
browser = get_selenium(url)

for profile in browser.find_elements(By.CSS_SELECTOR, "li[class='item_box']"):
name_tag = profile.find_element(By.CSS_SELECTOR, "li[class='name']")
name = name_tag.text if name_tag else "이름 정보 없음"

party_tag = profile.find_element(By.CSS_SELECTOR, "li[class='item PA']")
party = party_tag.text if party_tag else "정당 정보 없음"

# TODO
councilors.append(Councilor(name, party))

return ScrapResult(
council_id="gwangju",
Expand Down Expand Up @@ -534,4 +541,4 @@ def scrap_metro_17(


if __name__ == "__main__":
print(scrap_metro_17())
print(scrap_metro_5())

0 comments on commit ac71f41

Please sign in to comment.