Skip to content

Commit

Permalink
Merge branch '14-create-andong' of https://github.com/NewWays-TechFor…
Browse files Browse the repository at this point in the history
  • Loading branch information
happycastle114 committed Nov 15, 2023
2 parents 32c967a + 46a6744 commit e3be5d4
Show file tree
Hide file tree
Showing 34 changed files with 427 additions and 279 deletions.
10 changes: 7 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from scrap.local_councils.gyeongsangbuk import scrap_andong, scrap_pohang, scrap_gyeongju
from scrap.local_councils.gyeongsangbuk import (
scrap_andong,
scrap_pohang,
scrap_gyeongju,
)

if __name__ == '__main__':
print(scrap_gyeongju())
if __name__ == "__main__":
print(scrap_gyeongju())
2 changes: 1 addition & 1 deletion scrap/local_councils/gyeongsangbuk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
from .gimcheon import scrap_gimcheon
from .sangju import scrap_sangju
from .moongyeong import scrap_moongyeong
from .yaecheon import scrap_yaecheon
from .yaecheon import scrap_yaecheon
18 changes: 10 additions & 8 deletions scrap/local_councils/gyeongsangbuk/andong.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@

import re

def scrap_andong(url = 'https://council.andong.go.kr/kr/member/name.do') -> ScrapResult:
'''대전시 동구 페이지에서 의원 상세약력 스크랩

def scrap_andong(url="https://council.andong.go.kr/kr/member/name.do") -> ScrapResult:
"""대전시 동구 페이지에서 의원 상세약력 스크랩
:param url: 의원 목록 사이트 url
:return: 의원들의 이름과 정당 데이터를 담은 ScrapResult 객체
'''
"""

soup = get_soup(url, verify=False)
councilors: List[Councilor] = []

for profile in soup.find_all('div', class_='profile'):
for profile in soup.find_all("div", class_="profile"):
name_tag = profile.find("em", class_="name")
name = name_tag.get_text(strip=True) if name_tag else "이름 정보 없음"

Expand All @@ -29,8 +30,9 @@ def scrap_andong(url = 'https://council.andong.go.kr/kr/member/name.do') -> Scra
return ScrapResult(
council_id="andong",
council_type=CouncilType.LOCAL_COUNCIL,
councilors=councilors
councilors=councilors,
)

if __name__ == '__main__':
print(scrap_andong())

if __name__ == "__main__":
print(scrap_andong())
20 changes: 11 additions & 9 deletions scrap/local_councils/gyeongsangbuk/gimcheon.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@
from scrap.utils.requests import get_soup
import re

def scrap_gimcheon(url = 'https://council.gc.go.kr/kr/member/active.do') -> ScrapResult:
'''김천시 페이지에서 의원 상세약력 스크랩

def scrap_gimcheon(url="https://council.gc.go.kr/kr/member/active.do") -> ScrapResult:
"""김천시 페이지에서 의원 상세약력 스크랩
:param url: 의원 목록 사이트 url
:return: 의원들의 이름과 정당 데이터를 담은 ScrapResult 객체
'''
"""

soup = get_soup(url, verify=False)
councilors: List[Councilor] = []
mlist = soup.find_all('ul', class_='memberList')[0]
mlist = soup.find_all("ul", class_="memberList")[0]

for profile in mlist.find_all('li', recursive=False):
for profile in mlist.find_all("li", recursive=False):
name_tag = profile.find("h4")
name = name_tag.get_text(strip=True) if name_tag else "이름 정보 없음"

Expand All @@ -29,8 +30,9 @@ def scrap_gimcheon(url = 'https://council.gc.go.kr/kr/member/active.do') -> Scra
return ScrapResult(
council_id="gimcheon",
council_type=CouncilType.LOCAL_COUNCIL,
councilors=councilors
councilors=councilors,
)

if __name__ == '__main__':
print(scrap_gimcheon())

if __name__ == "__main__":
print(scrap_gimcheon())
24 changes: 13 additions & 11 deletions scrap/local_councils/gyeongsangbuk/gumi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@
from scrap.utils.requests import get_soup
import re

def scrap_gumi(url = 'https://gumici.or.kr/content/member/memberName.html') -> ScrapResult:
'''대전시 동구 페이지에서 의원 상세약력 스크랩

def scrap_gumi(
url="https://gumici.or.kr/content/member/memberName.html",
) -> ScrapResult:
"""대전시 동구 페이지에서 의원 상세약력 스크랩
:param url: 의원 목록 사이트 url
:return: 의원들의 이름과 정당 데이터를 담은 ScrapResult 객체
'''
"""

soup = get_soup(url, verify=False)
councilors: List[Councilor] = []
mlist = soup.find_all('ul', class_='mlist')[0]
mlist = soup.find_all("ul", class_="mlist")[0]

for profile in mlist.find_all('li'):
for profile in mlist.find_all("li"):
name_tag = profile.find("dd", class_="name")
name = name_tag.get_text(strip=True) if name_tag else "이름 정보 없음"

Expand All @@ -27,10 +30,9 @@ def scrap_gumi(url = 'https://gumici.or.kr/content/member/memberName.html') -> S
councilors.append(Councilor(name=name, party=party))

return ScrapResult(
council_id="gumi",
council_type=CouncilType.LOCAL_COUNCIL,
councilors=councilors
council_id="gumi", council_type=CouncilType.LOCAL_COUNCIL, councilors=councilors
)

if __name__ == '__main__':
print(scrap_gumi())

if __name__ == "__main__":
print(scrap_gumi())
26 changes: 15 additions & 11 deletions scrap/local_councils/gyeongsangbuk/gyeongju.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,36 @@
import re
import requests

def scrap_gyeongju(url = 'https://council.gyeongju.go.kr/kr/member/name.do') -> ScrapResult:
'''대전시 동구 페이지에서 의원 상세약력 스크랩

def scrap_gyeongju(
url="https://council.gyeongju.go.kr/kr/member/name.do",
) -> ScrapResult:
"""대전시 동구 페이지에서 의원 상세약력 스크랩
:param url: 의원 목록 사이트 url
:return: 의원들의 이름과 정당 데이터를 담은 ScrapResult 객체
'''
"""

soup = get_soup(url, verify=False)
councilors: List[Councilor] = []

for profile in soup.find_all('div', class_="profile"):
for profile in soup.find_all("div", class_="profile"):
data_uid = profile.find("a", class_="btn_profile")["data-uid"]

if data_uid:
url = f"https://council.gyeongju.go.kr/common/async/member/{data_uid}.do"
result = requests.get(url).json()
name = result['name'] if result['name'] else "이름 정보 없음"
party = result['party_nm'] if result['party_nm'] else "정당 정보 없음"
name = result["name"] if result["name"] else "이름 정보 없음"
party = result["party_nm"] if result["party_nm"] else "정당 정보 없음"

councilors.append(Councilor(name=name, party=party))

return ScrapResult(
council_id="gyeongju",
council_type=CouncilType.LOCAL_COUNCIL,
councilors=councilors
councilors=councilors,
)

if __name__ == '__main__':
print(scrap_gyeongju())

if __name__ == "__main__":
print(scrap_gyeongju())
24 changes: 13 additions & 11 deletions scrap/local_councils/gyeongsangbuk/moongyeong.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,34 @@
import re
import requests

def scrap_moongyeong(url = 'https://council.gbmg.go.kr/kr/member/name.do') -> ScrapResult:
'''문경시 페이지에서 의원 상세약력 스크랩

def scrap_moongyeong(url="https://council.gbmg.go.kr/kr/member/name.do") -> ScrapResult:
"""문경시 페이지에서 의원 상세약력 스크랩
:param url: 의원 목록 사이트 url
:return: 의원들의 이름과 정당 데이터를 담은 ScrapResult 객체
'''
"""

soup = get_soup(url, verify=False)
councilors: List[Councilor] = []

for profile in soup.find_all('div', class_="profile"):
for profile in soup.find_all("div", class_="profile"):
data_uid = profile.find("a", class_="btn_profile")["data-uid"]

if data_uid:
url = f"https://council.gbmg.go.kr/common/async/member/{data_uid}.do"
result = requests.get(url).json()
name = result['name'] if result['name'] else "이름 정보 없음"
party = result['party_nm'] if result['party_nm'] else "정당 정보 없음"
name = result["name"] if result["name"] else "이름 정보 없음"
party = result["party_nm"] if result["party_nm"] else "정당 정보 없음"

councilors.append(Councilor(name=name, party=party))

return ScrapResult(
council_id="moongyeong",
council_type=CouncilType.LOCAL_COUNCIL,
councilors=councilors
councilors=councilors,
)

if __name__ == '__main__':
print(scrap_moongyeong())

if __name__ == "__main__":
print(scrap_moongyeong())
22 changes: 13 additions & 9 deletions scrap/local_councils/gyeongsangbuk/pohang.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@
from scrap.utils.requests import get_soup
import re

def scrap_pohang(url = 'https://council.pohang.go.kr/content/member/memberName.html') -> ScrapResult:
'''대전시 동구 페이지에서 의원 상세약력 스크랩

def scrap_pohang(
url="https://council.pohang.go.kr/content/member/memberName.html",
) -> ScrapResult:
"""대전시 동구 페이지에서 의원 상세약력 스크랩
:param url: 의원 목록 사이트 url
:return: 의원들의 이름과 정당 데이터를 담은 ScrapResult 객체
'''
"""

soup = get_soup(url, verify=False)
councilors: List[Councilor] = []
mlist = soup.find_all('ul', class_='mlist')[0]
mlist = soup.find_all("ul", class_="mlist")[0]

for profile in mlist.find_all('li'):
for profile in mlist.find_all("li"):
name_tag = profile.find("dd", class_="name")
name = name_tag.get_text(strip=True) if name_tag else "이름 정보 없음"

Expand All @@ -29,8 +32,9 @@ def scrap_pohang(url = 'https://council.pohang.go.kr/content/member/memberName.h
return ScrapResult(
council_id="pohang",
council_type=CouncilType.LOCAL_COUNCIL,
councilors=councilors
councilors=councilors,
)

if __name__ == '__main__':
print(scrap_pohang())

if __name__ == "__main__":
print(scrap_pohang())
20 changes: 12 additions & 8 deletions scrap/local_councils/gyeongsangbuk/sangju.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@

import re

def scrap_sangju(url = 'https://www.sangjucouncil.go.kr/kr/member/name.do') -> ScrapResult:
'''대전시 동구 페이지에서 의원 상세약력 스크랩

def scrap_sangju(
url="https://www.sangjucouncil.go.kr/kr/member/name.do",
) -> ScrapResult:
"""대전시 동구 페이지에서 의원 상세약력 스크랩
:param url: 의원 목록 사이트 url
:return: 의원들의 이름과 정당 데이터를 담은 ScrapResult 객체
'''
"""

soup = get_soup(url, verify=False)
councilors: List[Councilor] = []

for profile in soup.find_all('div', class_='profile'):
for profile in soup.find_all("div", class_="profile"):
name_tag = profile.find("div", class_="name").find("strong")
name = name_tag.get_text(strip=True) if name_tag else "이름 정보 없음"

Expand All @@ -29,8 +32,9 @@ def scrap_sangju(url = 'https://www.sangjucouncil.go.kr/kr/member/name.do') -> S
return ScrapResult(
council_id="sangju",
council_type=CouncilType.LOCAL_COUNCIL,
councilors=councilors
councilors=councilors,
)

if __name__ == '__main__':
print(scrap_sangju())

if __name__ == "__main__":
print(scrap_sangju())
24 changes: 13 additions & 11 deletions scrap/local_councils/gyeongsangbuk/yaecheon.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,34 @@

import re

def scrap_yaecheon(url = 'https://www.ycgcl.kr/kr/member/name.do') -> ScrapResult:
'''예천시 페이지에서 의원 상세약력 스크랩

def scrap_yaecheon(url="https://www.ycgcl.kr/kr/member/name.do") -> ScrapResult:
"""예천시 페이지에서 의원 상세약력 스크랩
:param url: 의원 목록 사이트 url
:return: 의원들의 이름과 정당 데이터를 담은 ScrapResult 객체
'''
"""

soup = get_soup(url, verify=False)
councilors: List[Councilor] = []

for profile in soup.find_all('div', class_="profile"):
for profile in soup.find_all("div", class_="profile"):
data_uid = profile.find("a", class_="btn_profile")["data-uid"]

if data_uid:
url = f"https://www.ycgcl.kr/common/async/member/{data_uid}.do"
result = requests.get(url).json()
name = result['name'] if result['name'] else "이름 정보 없음"
party = result['party_nm'] if result['party_nm'] else "정당 정보 없음"
name = result["name"] if result["name"] else "이름 정보 없음"
party = result["party_nm"] if result["party_nm"] else "정당 정보 없음"

councilors.append(Councilor(name=name, party=party))

return ScrapResult(
council_id="yaecheon",
council_type=CouncilType.LOCAL_COUNCIL,
councilors=councilors
councilors=councilors,
)

if __name__ == '__main__':
print(scrap_yaecheon())

if __name__ == "__main__":
print(scrap_yaecheon())
Loading

0 comments on commit e3be5d4

Please sign in to comment.