質問編集履歴

1

試行錯誤のために作成していたほうのファイルを投稿していました。

2019/10/12 18:20

投稿

Yuu412
Yuu412

スコア37

test CHANGED
File without changes
test CHANGED
@@ -118,7 +118,7 @@
118
118
 
119
119
  #URLを取得
120
120
 
121
- URL = post.find_element_by_tag_name("a").get_attribute("href")
121
+ URL = post.find_element_by_css_selector("a").get_attribute("href")
122
122
 
123
123
  se = pd.series([title, price, sold, URL],columns)
124
124
 
@@ -164,10 +164,36 @@
164
164
 
165
165
  Traceback (most recent call last):
166
166
 
167
- File "C:\Users\user\Documents\Python\testes.py", line 55, in <module>
167
+ File "C:\Python\test0.py", line 55, in <module>
168
168
 
169
- URL = elem.find_element_by_tag_name("a").get_attribute("href")
169
+ URL = post.find_element_by_css_selector("a").get_attribute("href")
170
170
 
171
+ File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 430, in find_element_by_css_selector
172
+
173
+ return self.find_element(by=By.CSS_SELECTOR, value=css_selector)
174
+
175
+ File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 659, in find_element
176
+
177
+ {"using": by, "value": value})['value']
178
+
179
+ File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
180
+
181
+ return self._parent.execute(command, params)
182
+
183
+ File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
184
+
171
- NameError: name 'elem' is not defined
185
+ self.error_handler.check_response(response)
186
+
187
+ File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
188
+
189
+ raise exception_class(message, screen, stacktrace)
190
+
191
+ selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"a"}
192
+
193
+ (Session info: chrome=77.0.3865.120)
194
+
195
+
196
+
197
+
172
198
 
173
199
  ```