728x90
from urllib.request import urlopen
from bs4 import BeautifulSoup
html = urlopen("http://ncov.mohw.go.kr/bdBoardList_Real.do?brdId=1&brdGubun=11&ncvContSeq=&contSeq=&board_id=&gubun=")
bsObject = BeautifulSoup(html, "html.parser")
#print(bsObject)
table = bsObject.find('table', {'class':'num'})
trs = table.find_all('tr')
for idx, tr in enumerate(trs):
if idx >= 0:
tds = tr.find_all('td')
ths = tr.find_all('th')
print(tds[0].text.strip(), ths[0].text.strip())
python test.py
만약 실행이 안되면
pip install beautifulsoup4를 사용해서 설치하자
728x90
'개발 업무(코딩)-개발자였을때 썼던..' 카테고리의 다른 글
pypy3 설치하는 방법 (0) | 2023.01.08 |
---|---|
vim color 편집하기 (0) | 2023.01.08 |
c언어 함수포인터(fp) function pointer 간단 예제 (0) | 2023.01.08 |
TR전문 자르는 방식 예제(많이 쓰는 형태여서 예시코드 작성) (0) | 2023.01.08 |
c와 mariadb 연결하는 방법 및 예제 3 - insert+update 한번에 (0) | 2023.01.08 |