回答編集履歴
4
回答を編集する
test
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
|
25
25
|
for menu in lists:
|
26
26
|
|
27
|
-
print(menu)
|
27
|
+
print(menu.text)
|
28
28
|
|
29
29
|
|
30
30
|
|
3
回答を編集する
test
CHANGED
@@ -2,13 +2,33 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
"//h4/../div/div"
|
5
|
+
"//h4/../div[1]/div"
|
6
6
|
|
7
7
|
|
8
8
|
|
9
9
|
でしょうか?
|
10
10
|
|
11
|
+
```Python
|
11
12
|
|
13
|
+
import lxml.html
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
~~ 略~~
|
18
|
+
|
19
|
+
dom = lxml.html.fromstring(driver.page_source)
|
20
|
+
|
21
|
+
lists = dom.xpath("//h4/../div[1]/div")
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
for menu in lists:
|
26
|
+
|
27
|
+
print(menu)
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
```
|
12
32
|
|
13
33
|
|
14
34
|
|
2
追記
test
CHANGED
@@ -15,3 +15,17 @@
|
|
15
15
|
これで 取得できるなら
|
16
16
|
|
17
17
|
.parent を使えばよい?
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
```Python
|
24
|
+
|
25
|
+
for h4 in soup.find_all('h4'):
|
26
|
+
|
27
|
+
menu = h4.parent.select_one("div > div").text
|
28
|
+
|
29
|
+
print(menu)
|
30
|
+
|
31
|
+
```
|
1
追記
test
CHANGED
@@ -7,3 +7,11 @@
|
|
7
7
|
|
8
8
|
|
9
9
|
でしょうか?
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
これで 取得できるなら
|
16
|
+
|
17
|
+
.parent を使えばよい?
|