teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

リンク修正

2020/06/29 15:09

投稿

kotori_a
kotori_a

スコア898

answer CHANGED
@@ -1,7 +1,7 @@
1
1
  [title = div.h2 を soup.find('h2').get_text() に変更するとraise TemplateNotFound(template)が発生する理由]
2
2
 
3
3
  上記の~.pyファイルと同じフォルダにtemplateフォルダを作り、その中にindex.htmlとlayout.htmlを作成していないからではないでしょうか。
4
- (index.htmlの中身は[ここ](https://github.com/alumi-mic/flasksample-hatebu/blob/master/templates/layout.html)、
4
+ (index.htmlの中身は[ここ](https://github.com/alumi-mic/flasksample-hatebu/blob/master/templates/index.html)、
5
5
  layout.htmlの中身は[ここ](https://github.com/alumi-mic/flasksample-hatebu/blob/master/templates/layout.html)の通りになっている必要があります)
6
6
 
7
7
  あと、(templateフォルダおよびその中にindex.html、layout.htmlを作成したうえで)

1

修正

2020/06/29 15:09

投稿

kotori_a
kotori_a

スコア898

answer CHANGED
@@ -4,11 +4,11 @@
4
4
  (index.htmlの中身は[ここ](https://github.com/alumi-mic/flasksample-hatebu/blob/master/templates/layout.html)、
5
5
  layout.htmlの中身は[ここ](https://github.com/alumi-mic/flasksample-hatebu/blob/master/templates/layout.html)の通りになっている必要があります)
6
6
 
7
- あと、元ソースで
7
+ あと、(templateフォルダおよびその中にindex.htmllayout.htmlを作成したうえで)
8
8
  title = div.h2 を soup.find('h2').get_text()
9
9
  とする必要はなく、
10
10
  title = div.h3
11
- とすると、元のAttributeError: 'NoneType' object has no attribute 'getText'エラーは
11
+ とすれば、元のAttributeError: 'NoneType' object has no attribute 'getText'エラーは
12
12
  発生しなくなると思います。
13
13
 
14
14