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

回答編集履歴

2

微修正

2020/05/25 12:13

投稿

otn
otn

スコア86349

answer CHANGED
@@ -5,8 +5,8 @@
5
5
  #追記
6
6
  ```Python
7
7
  全部取得して、onmouseoverがなければ無視
8
- x = [area for area in soup.find_all("area") if area.has_attr("onmouseover")]
8
+ area = [tag for tag in soup.find_all("area") if tag.has_attr("onmouseover")]
9
9
 
10
10
  条件で何とかする
11
- y = soup.find_all(lambda tag: tag.name=="area" and tag.has_attr("onmouseover"))
11
+ area = soup.find_all(lambda tag: tag.name=="area" and tag.has_attr("onmouseover"))
12
12
  ```

1

追記

2020/05/25 12:12

投稿

otn
otn

スコア86349

answer CHANGED
@@ -1,3 +1,12 @@
1
1
  > onmouseoverがある行だけを抜き出したいのですが、どのように指定すれば良いのでしょうか?
2
2
 
3
- 全部取得して、onmouseoverがなければ無視すれば良いのでは?
3
+ 全部取得して、onmouseoverがなければ無視すれば良いのでは?
4
+
5
+ #追記
6
+ ```Python
7
+ 全部取得して、onmouseoverがなければ無視
8
+ x = [area for area in soup.find_all("area") if area.has_attr("onmouseover")]
9
+
10
+ 条件で何とかする
11
+ y = soup.find_all(lambda tag: tag.name=="area" and tag.has_attr("onmouseover"))
12
+ ```