回答編集履歴
3
間違いを修正
test
CHANGED
@@ -28,7 +28,7 @@
|
|
28
28
|
|
29
29
|
```python
|
30
30
|
|
31
|
-
elements = driver.find_elements_by_css_selector("body > table tr:nth-of-type(10) tr:nth-of-type(2n+3) td:nth-of-type(2) b:first-of-type")
|
31
|
+
elements = driver.find_elements_by_css_selector("body > table tr:nth-of-type(10) tr tr:nth-of-type(2n+3) td:nth-of-type(2) b:first-of-type")
|
32
32
|
|
33
33
|
```
|
34
34
|
|
2
説明を追記
test
CHANGED
@@ -14,7 +14,21 @@
|
|
14
14
|
|
15
15
|
```python
|
16
16
|
|
17
|
-
elements = driver.find_elements_by_css_selector("table tbody tr:nth-of-type(10) td table tbody tr td table tbody tr:nth-of-type(2n+3) td:nth-of-type(2) b:first-of-type")
|
17
|
+
elements = driver.find_elements_by_css_selector("body > table > tbody > tr:nth-of-type(10) > td > table > tbody > tr > td > table > tbody > tr:nth-of-type(2n+3) > td:nth-of-type(2) > b:first-of-type")
|
18
|
+
|
19
|
+
```
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
実際はXPathほど厳密に辿らなくてもいいので、以下のような感じでしょうか。
|
24
|
+
|
25
|
+
取得先のHTMLを見て適宜変えてください。
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
```python
|
30
|
+
|
31
|
+
elements = driver.find_elements_by_css_selector("body > table tr:nth-of-type(10) tr:nth-of-type(2n+3) td:nth-of-type(2) b:first-of-type")
|
18
32
|
|
19
33
|
```
|
20
34
|
|
1
Selenium用に変更
test
CHANGED
@@ -12,17 +12,9 @@
|
|
12
12
|
|
13
13
|
|
14
14
|
|
15
|
-
どのライブラリを使って
|
16
|
-
|
17
|
-
らっしゃるかわからないので、とりあえずBeautiful Soupでの例を挙げておきます。
|
18
|
-
|
19
|
-
Seleniumでも`driver.find_elements_by_css_selector()`などで同様のことができます。
|
20
|
-
|
21
|
-
|
22
|
-
|
23
15
|
```python
|
24
16
|
|
25
|
-
elements =
|
17
|
+
elements = driver.find_elements_by_css_selector("table tbody tr:nth-of-type(10) td table tbody tr td table tbody tr:nth-of-type(2n+3) td:nth-of-type(2) b:first-of-type")
|
26
18
|
|
27
19
|
```
|
28
20
|
|