質問編集履歴

2

エラー追記しました

2024/01/12 19:40

投稿

Gadget
Gadget

スコア8

test CHANGED
File without changes
test CHANGED
@@ -12,9 +12,21 @@
12
12
 
13
13
  ### エラーメッセージ
14
14
  ```error
15
+ Traceback (most recent call last):
16
+ File "/Users...", line 28, in <module>
17
+ FIND_PLACE = browser.find_element(By.XPATH, "/html/body/table")
18
+ File "/Users...", line 742, in find_element
19
+ return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
20
+ File "/Users...", line 348, in execute
21
+ self.error_handler.check_response(response)
22
+ File "/Users...", line 229, in check_response
23
+ raise exception_class(message, screen, stacktrace)
15
24
  selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/table"}
16
- (Session info: chrome-headless-shell=120.0.6099.216); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
25
+ (Session info: chrome=120.0.6099.216); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
17
26
  Stacktrace:
27
+ 0 chromedriver 0x000000010ad75cc8 chromedriver + 4844744
28
+ ##略
29
+
18
30
  ```
19
31
 
20
32
  ### 該当のソースコード

1

ソースコードを追記しました。どのようにお伝えすればよいかわかっていない部分もあり、不足があればまた追記させていただきます。

2024/01/12 19:33

投稿

Gadget
Gadget

スコア8

test CHANGED
File without changes
test CHANGED
@@ -18,6 +18,63 @@
18
18
  ```
19
19
 
20
20
  ### 該当のソースコード
21
+
22
+ 取得したいのはhrefリンクとChanel Signature De Chanelのような商品名のテキスト部分です。
23
+ 全体像は以下の通りです。
24
+ ```ここに言語を入力
25
+ <html>
26
+ <head>
27
+ <meta name="console-scheme" content="light dark">
28
+ </head>
29
+ <body>
30
+ <div class="line-gutter-backdrop"></div>
31
+ <form autocomplete="off">
32
+ <label class="line-wrap-control"></label>
33
+ </form>
34
+ <table>
35
+ <tbody>
36
+ <tr></tr>
37
+ <tr></tr>
38
+   略
39
+ <tr>
40
+     <td class="line-number" value="268"></td>
41
+ <td class="line-content">
42
+ <span class="html-tag">
43
+ "<a "
44
+ <span class="html-attribute-value html-external-link" target="blank"
45
+ href="/products/chanel-signature-de-chanel" rel="noneferrer noopener">
46
+ /products/chanel-signature-de-chanel</a>
47
+ "" "
48
+ <span class="html-attribute-value">klavika simpletextlistitem</span>
49
+ "">"
50
+ </span>
51
+ "Chanel Signature De Chanel"
52
+ ```
53
+
54
+ 該当箇所のdiv内は以下の通りです。
55
+ ```ここに言語を入力
56
+ <div class="paddingbl">
57
+
58
+
59
+   <a href="/products/chanel-signature-de-chanel" class="klavika simpletextlistitem">Chanel Signature De Chanel</a>
60
+
61
+   <a href="/products/chanel-ndeg1-de-chanel-revitalizing-serum" class="klavika simpletextlistitem">Chanel N°1 De Chanel Revitalizing Serum</a>
62
+
63
+ ##略
64
+ <div class="home-create-box paddingt30">
65
+ <span>
66
+ Can't find what you are looking for?
67
+ <span class="search-bumper hideotablet"></span>
68
+ <a href="/products/create">
69
+ <button>
70
+ <img src="https://incidecoder-assets.storage.googleapis.com/assets/img/star_goodie.png" alt=""></img>
71
+ UPLOAD IT
72
+ </button>
73
+ </a>
74
+ </span>
75
+ </div>
76
+ </div>
77
+ ```
21
78
 
22
79
  ```python
23
80
  from selenium import webdriver
@@ -41,6 +98,7 @@
41
98
 
42
99
  browser.find_element(By.ID, "query").send_keys('chanel')
43
100
  browser.find_element(By.XPATH, "//div[1]/div[2]/div[1]/form/input[2]").click()
101
+ input("つづける?")
44
102
  time.sleep(INTERVAL)
45
103
 
46
104
  ###
@@ -61,3 +119,4 @@
61
119
 
62
120
  ### 補足
63
121
  特になし
122
+