Update app.py
Browse files
app.py
CHANGED
@@ -37,6 +37,35 @@ def clone_repo():
|
|
37 |
# クローンを実行
|
38 |
clone_repo()
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
# Flaskアプリケーションの設定
|
41 |
app = Flask(__name__)
|
42 |
|
|
|
37 |
# クローンを実行
|
38 |
clone_repo()
|
39 |
|
40 |
+
from bs4 import BeautifulSoup
|
41 |
+
|
42 |
+
# index.htmlを読み込む関数
|
43 |
+
def modify_index_html():
|
44 |
+
try:
|
45 |
+
with open('index.html', 'r', encoding='utf-8') as file:
|
46 |
+
# BeautifulSoupでHTMLをパース
|
47 |
+
soup = BeautifulSoup(file, 'lxml')
|
48 |
+
|
49 |
+
# id="sectionRight"を取得
|
50 |
+
section_right = soup.find(id="sectionRight")
|
51 |
+
if section_right:
|
52 |
+
# id="store"を除くすべての子要素を空にする
|
53 |
+
for element in section_right.find_all(True): # Trueはすべてのタグを対象
|
54 |
+
if element.get('id') != 'store':
|
55 |
+
element.clear() # 要素の内容を空にする
|
56 |
+
|
57 |
+
# 変更を保存する
|
58 |
+
with open('index.html', 'w', encoding='utf-8') as file:
|
59 |
+
file.write(str(soup))
|
60 |
+
print("index.html has been modified successfully.")
|
61 |
+
|
62 |
+
except Exception as e:
|
63 |
+
print(f"An error occurred: {e}")
|
64 |
+
|
65 |
+
# 関数を実行
|
66 |
+
modify_index_html()
|
67 |
+
|
68 |
+
|
69 |
# Flaskアプリケーションの設定
|
70 |
app = Flask(__name__)
|
71 |
|