瀏覽代碼

증포중학교 급식정보

tobby48 5 年之前
父節點
當前提交
52d9578363
共有 1 個檔案被更改,包括 14 行新增0 行删除
  1. 14
    0
      src/main/python/kr/co/swh/lecture/opensource/html/schoolFood.py

+ 14
- 0
src/main/python/kr/co/swh/lecture/opensource/html/schoolFood.py 查看文件

@@ -0,0 +1,14 @@
1
+# https://irongaea.github.io/2018/07/29/bs4-select/
2
+import requests
3
+from bs4 import BeautifulSoup  # BeautifulSoup import
4
+
5
+while True:
6
+    yearmon = input("증포중학교 년월: (ex.201904)")
7
+    url = 'http://www.jpo.ms.kr/lunch.list?ym=' + yearmon
8
+    response = requests.get(url)
9
+    html = response.text
10
+    soup = BeautifulSoup(html, 'html.parser')  # html.parser를 사용해서 soup에 넣겠다
11
+    for day in soup.select('div[class="dayBox"]'):
12
+        print(day.select('span')[0].text)
13
+        print(day.select('div[class="content"] div[class="tabContent on"] a')[0].text.strip())
14
+        print("---------------------")