本帖最后由 DEEaka 于 2022-12-17 21:26 编辑
大佬。出错了咋办。户号是我手动处理掉的。
conts.py改过了,还是这样
2022-12-17 21:02:05 [INFO ] ---- Webdriver initialized.
2022-12-17 21:02:28 [INFO ] ---- Login successfully on https://www.95598.cn/osgweb/login
2022-12-17 21:02:34 [INFO ] ---- get all user id: ['户号1', '户号2', '户号3', '户号4', '户号5', '户号6', '户号7']
2022-12-17 21:02:43 [INFO ] ---- Get electricity charge balance for 户号1 successfully, balance is -35.94 CNY.
2022-12-17 21:02:46 [INFO ] ---- Get electricity charge balance for 户号2 successfully, balance is -35.38 CNY.
2022-12-17 21:03:06 [ERROR ] ---- Webdriver quit abnormly, reason: Message: no such element: Unable to locate element: {"method":"css selector","selector":".num"}
(Session info: headless chrome=90.0.4430.212)
Stacktrace:
#0 0x560f462d77f9 <unknown>
#1 0x560f462773b3 <unknown>
#2 0x560f45fbf016 <unknown>
#3 0x560f45ff381e <unknown>
#4 0x560f460298fb <unknown>
#5 0x560f46016ded <unknown>
#6 0x560f460279e1 <unknown>
#7 0x560f46016c93 <unknown>
#8 0x560f45fe8ce4 <unknown>
#9 0x560f45fea4d2 <unknown>
#10 0x560f462a3542 <unknown>
#11 0x560f462b2ce7 <unknown>
#12 0x560f462b29e4 <unknown>
#13 0x560f462b713a <unknown>
#14 0x560f462b35b9 <unknown>
#15 0x560f46298e00 <unknown>
#16 0x560f462ca5d2 <unknown>
#17 0x560f462ca778 <unknown>
#18 0x560f462e2a1f <unknown>
#19 0x7f87b7a26fa3 start_thread
#20 0x7f87b6c7d06f clone
. 1 retry times left.
Traceback (most recent call last):
File "/app/data_fetcher.py", line 30, in fetch
return self._fetch()
File "/app/data_fetcher.py", line 53, in _fetch
balance_list = self._get_electric_balances(driver, user_id_list)
File "/app/data_fetcher.py", line 126, in _get_electric_balances
balance = self._get_eletric_balance(driver)
File "/app/data_fetcher.py", line 183, in _get_eletric_balance
balance = driver.find_element(By.CLASS_NAME,"num").text
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 856, in find_element
return self.execute(Command.FIND_ELEMENT, {
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 429, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 243, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".num"}
(Session info: headless chrome=90.0.4430.212)
Stacktrace:
#0 0x560f462d77f9 <unknown>
#1 0x560f462773b3 <unknown>
#2 0x560f45fbf016 <unknown>
#3 0x560f45ff381e <unknown>
#4 0x560f460298fb <unknown>
#5 0x560f46016ded <unknown>
#6 0x560f460279e1 <unknown>
#7 0x560f46016c93 <unknown>
#8 0x560f45fe8ce4 <unknown>
#9 0x560f45fea4d2 <unknown>
#10 0x560f462a3542 <unknown>
#11 0x560f462b2ce7 <unknown>
#12 0x560f462b29e4 <unknown>
#13 0x560f462b713a <unknown>
#14 0x560f462b35b9 <unknown>
#15 0x560f46298e00 <unknown>
#16 0x560f462ca5d2 <unknown>
#17 0x560f462ca778 <unknown>
#18 0x560f462e2a1f <unknown>
#19 0x7f87b7a26fa3 start_thread
#20 0x7f87b6c7d06f clone
2022-12-17 21:03:47 [INFO ] ---- Webdriver initialized.
2022-12-17 21:04:09 [INFO ] ---- Login successfully on https://www.95598.cn/osgweb/login
2022-12-17 21:04:14 [INFO ] ---- get all user id: ['户号1', '户号2', '户号3', '户号4', '户号5', '户号6', '户号7']
2022-12-17 21:04:24 [INFO ] ---- Get electricity charge balance for 户号1 successfully, balance is -35.94 CNY.
2022-12-17 21:04:27 [INFO ] ---- Get electricity charge balance for 户号2 successfully, balance is -35.38 CNY.
2022-12-17 21:04:47 [ERROR ] ---- state-refresh task failed, reason is Message: no such element: Unable to locate element: {"method":"css selector","selector":".num"}
(Session info: headless chrome=90.0.4430.212)
Stacktrace:
#0 0x556380ca47f9 <unknown>
#1 0x556380c443b3 <unknown>
#2 0x55638098c016 <unknown>
#3 0x5563809c081e <unknown>
#4 0x5563809f68fb <unknown>
#5 0x5563809e3ded <unknown>
#6 0x5563809f49e1 <unknown>
#7 0x5563809e3c93 <unknown>
#8 0x5563809b5ce4 <unknown>
#9 0x5563809b74d2 <unknown>
#10 0x556380c70542 <unknown>
#11 0x556380c7fce7 <unknown>
#12 0x556380c7f9e4 <unknown>
#13 0x556380c8413a <unknown>
#14 0x556380c805b9 <unknown>
#15 0x556380c65e00 <unknown>
#16 0x556380c975d2 <unknown>
#17 0x556380c97778 <unknown>
#18 0x556380cafa1f <unknown>
#19 0x7f43b248afa3 start_thread
#20 0x7f43b16e106f clone
复制代码