从8月28日开始获取30天用电数据会报错,只能获取最近6天,其他天的数据全是空的,导致最后实体数据注册失败
Closed this issue · 4 comments
EricCorleone commented
2024-08-29 14:03:50 [INFO ] ---- 数据库: homeassistant.db 连接成功
2024-08-29 14:03:50 [INFO ] ---- 2024-08-28的用电量30KWh已经成功存入数据库
2024-08-29 14:03:50 [INFO ] ---- 2024-08-27的用电量30.02KWh已经成功存入数据库
2024-08-29 14:03:50 [INFO ] ---- 2024-08-26的用电量27.77KWh已经成功存入数据库
2024-08-29 14:03:50 [INFO ] ---- 2024-08-25的用电量33.55KWh已经成功存入数据库
2024-08-29 14:03:50 [INFO ] ---- 2024-08-24的用电量33.65KWh已经成功存入数据库
2024-08-29 14:03:50 [INFO ] ---- 2024-08-23的用电量24.02KWh已经成功存入数据库
Traceback (most recent call last):
File "/app/data_fetcher.py", line 251, in fetch
return self._fetch()
File "/app/data_fetcher.py", line 286, in _fetch
last_daily_date_list, last_daily_usage_list, yearly_charge_list, yearly_usage_list, month_list, month_usage_list, month_charge_list, usage, total_bill = self._get_other_data(
File "/app/data_fetcher.py", line 444, in _get_other_data
self.save_usage_data(driver, user_id_list[i - 1])
File "/app/data_fetcher.py", line 601, in save_usage_data
dic = {'date': day, 'usage': float(usage)}
ValueError: could not convert string to float: ''
2024-08-29 14:03:51 [ERROR ] ---- Webdriver quit abnormly, reason: could not convert string to float: ''. 5 retry times left.
2024-08-29 14:03:51 [ERROR ] ---- state-refresh task failed, reason is cannot unpack non-iterable NoneType object
Traceback (most recent call last):
File "/app/main.py", line 55, in run_task
user_id_list, balance_list, last_daily_date_list, last_daily_usage_list, yearly_charge_list, yearly_usage_list, month_list, month_usage_list, month_charge_list, usage, total_bill = data_fetcher.fetch()
TypeError: cannot unpack non-iterable NoneType object
EricCorleone commented
目前我只能是给dic = {'date': day, 'usage': float(usage)}
加个try,遇到报错就跳过:
sgcc_electricity_month_ladder | 2024-08-29 15:15:05 [INFO ] ---- 数据库: homeassistant.db 连接成功
sgcc_electricity_month_ladder | 2024-08-29 15:15:05 [INFO ] ---- 2024-08-28的用电量30KWh已经成功存入数据库
sgcc_electricity_month_ladder | 2024-08-29 15:15:05 [INFO ] ---- 2024-08-27的用电量30.02KWh已经成功存入数据库
sgcc_electricity_month_ladder | 2024-08-29 15:15:05 [INFO ] ---- 2024-08-26的用电量27.77KWh已经成功存入数据库
sgcc_electricity_month_ladder | 2024-08-29 15:15:05 [INFO ] ---- 2024-08-25的用电量33.55KWh已经成功存入数据库
sgcc_electricity_month_ladder | 2024-08-29 15:15:05 [INFO ] ---- 2024-08-24的用电量33.65KWh已经成功存入数据库
sgcc_electricity_month_ladder | 2024-08-29 15:15:05 [INFO ] ---- 2024-08-23的用电量24.02KWh已经成功存入数据库
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
sgcc_electricity_month_ladder | 转浮点数报错:could not convert string to float: ''
Kagamia commented
我也遇到了相同的问题,从11/27开始只能获取6条数据,后面就会报错
不清楚是不是因为原网站的数据绑定方式是不是虚拟绑定,表格太长看不见就不显示了...希望能寻找一个积极的修复方案。
ARC-MX commented
你先手动登录网站看看之前的数据是个啥数据再说吧,各地国网的数据都不一样
Kagamia commented
手动登录网站是可以看到全部的30天数据,不过因为网站反调试功能不太容易获取dom,看来需要手动创建driver登录测试了 😢