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

質問編集履歴

1

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

2019/10/12 18:20

投稿

Yuu412
Yuu412

スコア37

title CHANGED
File without changes
body CHANGED
@@ -58,7 +58,7 @@
58
58
  sold = 1
59
59
 
60
60
  #URLを取得
61
- URL = post.find_element_by_tag_name("a").get_attribute("href")
61
+ URL = post.find_element_by_css_selector("a").get_attribute("href")
62
62
  se = pd.series([title, price, sold, URL],columns)
63
63
  df = df.append(se, columns)
64
64
 
@@ -81,7 +81,20 @@
81
81
  ```エラー(ユーザー名をuserに変更している)
82
82
  1ページを取得中
83
83
  Traceback (most recent call last):
84
- File "C:\Users\user\Documents\Python\testes.py", line 55, in <module>
84
+ File "C:\Python\test0.py", line 55, in <module>
85
- URL = elem.find_element_by_tag_name("a").get_attribute("href")
85
+ URL = post.find_element_by_css_selector("a").get_attribute("href")
86
+ 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
87
+ return self.find_element(by=By.CSS_SELECTOR, value=css_selector)
88
+ File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 659, in find_element
89
+ {"using": by, "value": value})['value']
90
+ File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
91
+ return self._parent.execute(command, params)
92
+ File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
86
- NameError: name 'elem' is not defined
93
+ self.error_handler.check_response(response)
94
+ File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
95
+ raise exception_class(message, screen, stacktrace)
96
+ selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"a"}
97
+ (Session info: chrome=77.0.3865.120)
98
+
99
+
87
100
  ```