回答編集履歴

1

修正

2020/04/06 09:04

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -37,3 +37,49 @@
37
37
  print(a)
38
38
 
39
39
  ```
40
+
41
+
42
+
43
+ ## 追記
44
+
45
+
46
+
47
+ id="B" 以下のすべての li タグ
48
+
49
+
50
+
51
+ ```python
52
+
53
+ from bs4 import BeautifulSoup
54
+
55
+
56
+
57
+ html = """<div id="A">
58
+
59
+ <ul id="B">
60
+
61
+ <li>
62
+
63
+ <a href="http:C"></a>
64
+
65
+ </li>
66
+
67
+ <li></li>
68
+
69
+ <li></li>
70
+
71
+ </ul>
72
+
73
+ </div>"""
74
+
75
+
76
+
77
+ soup = BeautifulSoup(html, "lxml")
78
+
79
+
80
+
81
+ for li in soup.select("#B li"):
82
+
83
+ print(li)
84
+
85
+ ```