回答編集履歴
1
追記
answer
CHANGED
@@ -5,4 +5,12 @@
|
|
5
5
|
if 'ORANGE' in i.text:
|
6
6
|
print(i.parent.parent.parent.get('id').split('-')[-1])
|
7
7
|
# 1862374024
|
8
|
+
```
|
9
|
+
|
10
|
+
【コメントを受けての追記】
|
11
|
+
最初に見つかった要素のidを取得します。
|
12
|
+
```Python
|
13
|
+
target = soup.find(class_=['selectable msg-text-box _compile ng-scope'])
|
14
|
+
if 'ORANGE' in target.text:
|
15
|
+
print(target.parent.parent.parent.get('id').split('-')[-1])
|
8
16
|
```
|