soiz commited on
Commit
b1a989a
·
verified ·
1 Parent(s): 1f6c969

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -37,6 +37,7 @@ def clone_repo():
37
  # クローンを実行
38
  clone_repo()
39
 
 
40
  from bs4 import BeautifulSoup
41
 
42
  # index.htmlを読み込む関数
@@ -45,7 +46,7 @@ def modify_index_html():
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:
@@ -54,6 +55,14 @@ def modify_index_html():
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))
@@ -65,6 +74,7 @@ def modify_index_html():
65
  # 関数を実行
66
  modify_index_html()
67
 
 
68
 
69
  # Flaskアプリケーションの設定
70
  app = Flask(__name__)
 
37
  # クローンを実行
38
  clone_repo()
39
 
40
+ #HTMLの自動修正==========================
41
  from bs4 import BeautifulSoup
42
 
43
  # index.htmlを読み込む関数
 
46
  with open('index.html', 'r', encoding='utf-8') as file:
47
  # BeautifulSoupでHTMLをパース
48
  soup = BeautifulSoup(file, 'lxml')
49
+
50
  # id="sectionRight"を取得
51
  section_right = soup.find(id="sectionRight")
52
  if section_right:
 
55
  if element.get('id') != 'store':
56
  element.clear() # 要素の内容を空にする
57
 
58
+ # 新しい要素を作成して追加する
59
+ new_link = soup.new_tag('a', href="javascript:var s=document.createElement('script');s.type='text/javascript';s.src='https://sheeptester.github.io/javascripts/eval.js';document.body.appendChild(s);void(0);")
60
+ new_link.string = "javascriptコードを実行"
61
+ # id="store"の前に追加
62
+ store_element = section_right.find(id="store")
63
+ if store_element:
64
+ store_element.insert_before(new_link) # id="store"の前に追加
65
+
66
  # 変更を保存する
67
  with open('index.html', 'w', encoding='utf-8') as file:
68
  file.write(str(soup))
 
74
  # 関数を実行
75
  modify_index_html()
76
 
77
+ #修正用コードここまで============================
78
 
79
  # Flaskアプリケーションの設定
80
  app = Flask(__name__)