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

回答編集履歴

2

たびたび申し訳ございません。誤字などを修正しました。

2021/01/21 14:34

投稿

_whitecat_22
_whitecat_22

スコア1305

answer CHANGED
@@ -38,9 +38,13 @@
38
38
  以下のいずれかで、金額を取得することができますが、find_element_by_class_name="notranslate vi-VR-cvipPrice" ではエラーとなってしまいます。
39
39
 
40
40
  ```python
41
+ driver.find_element_by_class_name("s-item__link").click()
42
+ if str(driver.current_url) == url:
43
+ driver.find_element_by_class_name("s-item__link").click()
41
44
  ret = driver.find_element_by_css_selector(
42
- "div:nth-child(1) > table > tbody > tr:nth-child(6) > td > div > div:nth-child(2) > div.u-flL.w29.vi-price-np > span")
45
+ "div:nth-child(1) > table > tbody > tr:nth-child(6) > td > div > div:nth-child(2) > div.u-flL.w29.vi-price-np > span").text
43
- print(ret)
44
46
 
47
+ もしくは
48
+
45
49
  ret = driver.find_element_by_xpath('//*[@id = "mainContent"]/div[1]/table/tbody/tr[6]/td/div/div[2]/div[2]/span').text
46
50
  ```

1

追記しました。

2021/01/21 14:34

投稿

_whitecat_22
_whitecat_22

スコア1305

answer CHANGED
@@ -27,4 +27,20 @@
27
27
   
28
28
   
29
29
  (参考): Chromeのデベロッパーツールでの確認結果
30
- ![イメージ説明](e4b2f7767279170fe91c6f75940d416f.png)
30
+ ![イメージ説明](e4b2f7767279170fe91c6f75940d416f.png)
31
+
32
+  
33
+
34
+  
35
+ ---
36
+ 【再追記】
37
+
38
+ 以下のいずれかで、金額を取得することができますが、find_element_by_class_name="notranslate vi-VR-cvipPrice" ではエラーとなってしまいます。
39
+
40
+ ```python
41
+ ret = driver.find_element_by_css_selector(
42
+ "div:nth-child(1) > table > tbody > tr:nth-child(6) > td > div > div:nth-child(2) > div.u-flL.w29.vi-price-np > span")
43
+ print(ret)
44
+
45
+ ret = driver.find_element_by_xpath('//*[@id = "mainContent"]/div[1]/table/tbody/tr[6]/td/div/div[2]/div[2]/span').text
46
+ ```