|
发表于 2022-11-11 09:04:14
|
显示全部楼层
本帖最后由 pany4321 于 2022-11-11 09:12 编辑
好的,感谢感谢。昨晚上刚装上。重新启动几次Docker镜像,查看日志。感觉获取数据还不太稳定,晚上11点获取数据失败,早上8点获取数据成功。大神看看有没有改进的空间啊。日志如下:
-------------------------------------
2022-11-10 23:21:42 [INFO ] ---- Webdriver initialized.
2022-11-10 23:22:05 [ERROR ] ---- state-refresh task failed, reason is Message: no such element: Unable to locate element: {"method":"css selector","selector":".user"}
(Session info: headless chrome=90.0.4430.212)
Stacktrace:
#0 0x55bb6623b7f9 <unknown>
#1 0x55bb661db3b3 <unknown>
#2 0x55bb65f23016 <unknown>
#3 0x55bb65f5781e <unknown>
#4 0x55bb65f8d8fb <unknown>
#5 0x55bb65f7aded <unknown>
#6 0x55bb65f8b9e1 <unknown>
#7 0x55bb65f7ac93 <unknown>
#8 0x55bb65f4cce4 <unknown>
#9 0x55bb65f4e4d2 <unknown>
#10 0x55bb66207542 <unknown>
#11 0x55bb66216ce7 <unknown>
#12 0x55bb662169e4 <unknown>
#13 0x55bb6621b13a <unknown>
#14 0x55bb662175b9 <unknown>
#15 0x55bb661fce00 <unknown>
#16 0x55bb6622e5d2 <unknown>
#17 0x55bb6622e778 <unknown>
#18 0x55bb66246a1f <unknown>
#19 0x7f79782cafa3 start_thread
#20 0x7f797752106f clone
Traceback (most recent call last):
File "./main.py", line 27, in run_task
user_id_list, balance_list, last_daily_usage_list, yearly_charge_list, yearly_usage_list = data_fetcher.fetch()
File "/app/data_fetcher.py", line 33, in fetch
raise e
File "/app/data_fetcher.py", line 30, in fetch
return self._fetch()
File "/app/data_fetcher.py", line 47, in _fetch
self._login(driver)
File "/app/data_fetcher.py", line 83, in _login
driver.find_element(By.CLASS_NAME,"user").click()
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":".user"}
(Session info: headless chrome=90.0.4430.212)
Stacktrace:
#0 0x55bb6623b7f9 <unknown>
#1 0x55bb661db3b3 <unknown>
#2 0x55bb65f23016 <unknown>
#3 0x55bb65f5781e <unknown>
#4 0x55bb65f8d8fb <unknown>
#5 0x55bb65f7aded <unknown>
#6 0x55bb65f8b9e1 <unknown>
#7 0x55bb65f7ac93 <unknown>
#8 0x55bb65f4cce4 <unknown>
#9 0x55bb65f4e4d2 <unknown>
#10 0x55bb66207542 <unknown>
#11 0x55bb66216ce7 <unknown>
#12 0x55bb662169e4 <unknown>
#13 0x55bb6621b13a <unknown>
#14 0x55bb662175b9 <unknown>
#15 0x55bb661fce00 <unknown>
#16 0x55bb6622e5d2 <unknown>
#17 0x55bb6622e778 <unknown>
#18 0x55bb66246a1f <unknown>
#19 0x7f79782cafa3 start_thread
#20 0x7f797752106f clone
2022-11-11 08:00:03 [INFO ] ---- Webdriver initialized.
2022-11-11 08:04:48 [INFO ] ---- Login successfully on https://www.95598.cn/osgweb/login
2022-11-11 08:04:54 [INFO ] ---- get all user id: ['210XXXX600']
2022-11-11 08:07:14 [INFO ] ---- Get electricity charge balance for 210XXXX600 successfully, balance is 804.74 CNY.
2022-11-11 08:09:33 [INFO ] ---- Get year power consumption for 210XXXX600 successfully, usage is 3669 kwh, yealrly charge is 1831.03 CNY
2022-11-11 08:09:34 [INFO ] ---- Get daily power consumption for 210XXXX600 successfully, usage is 6.62 kwh.
2022-11-11 08:09:34 [INFO ] ---- Webdriver quit after fetching data successfully.
2022-11-11 08:09:35 [INFO ] ---- Homeassistant REST API invoke, POST on http://10.0.0.185:8123/api/state ... ity_charge_balance. response[201]: b'{"entity_id":"sensor.electricity_charge_balance","state":"804.74","attributes":{"unit_of_measurement":"CNY"},"last_changed":"2022-11-11T00:09:35.597975+00:00","last_updated":"2022-11-11T00:09:35.597975+00:00","context":{"id":"01GHJ0AF3DYY50EDJ74KN8EK0X","parent_id":null,"user_id":"62f52e10599e4f72a6023cb32bc1ef52"}}'
|
|