『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
楼主: louis_lee

[经验分享] Deprecated

  [复制链接]

3

主题

46

帖子

330

积分

中级会员

Rank: 3Rank: 3

积分
330
金钱
284
HASS币
0
发表于 2022-11-9 00:01:41 | 显示全部楼层
学习学习
回复

使用道具 举报

2

主题

33

帖子

582

积分

论坛技术达人

积分
582
金钱
544
HASS币
20
发表于 2022-11-9 05:55:31 | 显示全部楼层
支持一下
回复

使用道具 举报

5

主题

197

帖子

1465

积分

金牌会员

Rank: 6Rank: 6

积分
1465
金钱
1268
HASS币
0
发表于 2022-11-9 07:34:06 | 显示全部楼层
本帖最后由 459662146 于 2022-11-9 07:39 编辑

LOGIN_EXPECTED_TIME 由 5 改到20能登陆了
不过还是报错
2022-11-09 07:32:09  [INFO    ] ---- Service start!
2022-11-09 07:32:12  [INFO    ] ---- patching driver executable /usr/bin/chromedriver
2022-11-09 07:32:18  [INFO    ] ---- Webdriver initialized.
2022-11-09 07:32:58  [INFO    ] ---- Login successfully on https://www.95598.cn/osgweb/login
2022-11-09 07:33:58  [ERROR   ] ---- Webdriver quit abnormly, reason: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//li[@class='inline_block_fix zhanghu-full']//b[@class='cff8']"}
  (Session info: headless chrome=89.0.4389.114)
Stacktrace:
#0 0xaaaaad41cd48 <unknown>
#1 0xaaaaad3bf6cc <unknown>
#2 0xaaaaad152d84 <unknown>
#3 0xaaaaad17fe08 <unknown>
#4 0xaaaaad1adac8 <unknown>
#5 0xaaaaad176f50 <unknown>
#6 0xaaaaad1783d4 <unknown>
#7 0xaaaaad3eaec8 <unknown>
#8 0xaaaaad3f8aa0 <unknown>
#9 0xaaaaad3f8804 <unknown>
#10 0xaaaaad3fccbc <unknown>
#11 0xaaaaad3f9240 <unknown>
#12 0xaaaaad3e116c <unknown>
#13 0xaaaaad40fb3c <unknown>
#14 0xaaaaad427398 <unknown>
#15 0xffff857327e4 start_thread
#16 0xffff84df170c <unknown>
. 4 retry times left.
Traceback (most recent call last):
  File "/app/data_fetcher.py", line 28, in fetch
    return self._fetch()
  File "/app/data_fetcher.py", line 45, in _fetch
    balance = self._get_eletric_balance(driver)
  File "/app/data_fetcher.py", line 100, in _get_eletric_balance
    driver.find_element(By.XPATH,"//li[@class='inline_block_fix zhanghu-full']//b[@class='cff8']")
  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":"xpath","selector":"//li[@class='inline_block_fix zhanghu-full']//b[@class='cff8']"}
  (Session info: headless chrome=89.0.4389.114)
Stacktrace:
#0 0xaaaaad41cd48 <unknown>
#1 0xaaaaad3bf6cc <unknown>
#2 0xaaaaad152d84 <unknown>
#3 0xaaaaad17fe08 <unknown>
#4 0xaaaaad1adac8 <unknown>
#5 0xaaaaad176f50 <unknown>
#6 0xaaaaad1783d4 <unknown>
#7 0xaaaaad3eaec8 <unknown>
#8 0xaaaaad3f8aa0 <unknown>
#9 0xaaaaad3f8804 <unknown>
#10 0xaaaaad3fccbc <unknown>
#11 0xaaaaad3f9240 <unknown>
#12 0xaaaaad3e116c <unknown>
#13 0xaaaaad40fb3c <unknown>
#14 0xaaaaad427398 <unknown>
#15 0xffff857327e4 start_thread
#16 0xffff84df170c <unknown>
2022-11-09 07:34:31  [INFO    ] ---- Webdriver initialized.
2022-11-09 07:35:19  [INFO    ] ---- Login successfully on https://www.95598.cn/osgweb/login
2022-11-09 07:36:21  [ERROR   ] ---- Webdriver quit abnormly, reason: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//li[@class='inline_block_fix zhanghu-full']//b[@class='cff8']"}
  (Session info: headless chrome=89.0.4389.114)


回复

使用道具 举报

18

主题

587

帖子

4283

积分

元老级技术达人

积分
4283
金钱
3661
HASS币
182
 楼主| 发表于 2022-11-9 07:59:25 来自手机 | 显示全部楼层
本帖最后由 louis_lee 于 2022-11-9 08:03 编辑
459662146 发表于 2022-11-9 07:34
LOGIN_EXPECTED_TIME 由 5 改到20能登陆了
不过还是报错

看来就是性能问题,除了延长两个等待时间没有别的办法,可以再把driver_implicity....放到120
回复

使用道具 举报

6

主题

243

帖子

1864

积分

金牌会员

Rank: 6Rank: 6

积分
1864
金钱
1621
HASS币
0
发表于 2022-11-9 08:30:40 | 显示全部楼层
错误日志

orangepi@orangepizero2:~/install/sgcc_electricity$ sudo docker logs --tail=100  sgcc_electricity
2022-11-09 08:23:44  [INFO    ] ---- Service start!
2022-11-09 08:23:52  [INFO    ] ---- patching driver executable /usr/bin/chromedriver
2022-11-09 08:23:57  [INFO    ] ---- Webdriver initialized.
2022-11-09 08:24:34  [ERROR   ] ---- Webdriver quit abnormly, reason: Message: stale element reference: element is not attached to the page document
  (Session info: headless chrome=89.0.4389.114)
Stacktrace:
#0 0xaaaac06fdd48 <unknown>
#1 0xaaaac06a06cc <unknown>
#2 0xaaaac0433d84 <unknown>
#3 0xaaaac0436d48 <unknown>
#4 0xaaaac0436ba4 <unknown>
#5 0xaaaac0436e08 <unknown>
#6 0xaaaac0460b24 <unknown>
#7 0xaaaac0459ae0 <unknown>
#8 0xaaaac048eac8 <unknown>
#9 0xaaaac0457f50 <unknown>
#10 0xaaaac04593d4 <unknown>
#11 0xaaaac06cbec8 <unknown>
#12 0xaaaac06d9aa0 <unknown>
#13 0xaaaac06d9804 <unknown>
#14 0xaaaac06ddcbc <unknown>
#15 0xaaaac06da240 <unknown>
#16 0xaaaac06c216c <unknown>
#17 0xaaaac06f0b3c <unknown>
#18 0xaaaac0708398 <unknown>
#19 0xffffb9b637e4 start_thread
#20 0xffffb922270c <unknown>
. 4 retry times left.
Traceback (most recent call last):
回复

使用道具 举报

0

主题

19

帖子

415

积分

中级会员

Rank: 3Rank: 3

积分
415
金钱
396
HASS币
0
发表于 2022-11-9 09:13:41 | 显示全部楼层
隔壁的王叔叔 发表于 2022-11-8 14:36
tsp平台是啥呀?请大神解惑

蔚来的云端数据平台
回复

使用道具 举报

18

主题

587

帖子

4283

积分

元老级技术达人

积分
4283
金钱
3661
HASS币
182
 楼主| 发表于 2022-11-9 09:17:37 | 显示全部楼层
liantianji 发表于 2022-11-9 08:30
错误日志

orangepi@orangepizero2:~/install/sgcc_electricity$ sudo docker logs --tail=100  sgcc_elect ...

还有更详细的log嘛,包含Traceback,具体到哪个py文件的哪一行的。

我猜是由于性能弱,跳转慢造成的,不行只能在每个click()后,加个time.sleep(3)睡个3秒看看。
回复

使用道具 举报

5

主题

197

帖子

1465

积分

金牌会员

Rank: 6Rank: 6

积分
1465
金钱
1268
HASS币
0
发表于 2022-11-9 09:36:11 | 显示全部楼层
两个等待时间已经延长,还是不行。
回复

使用道具 举报

5

主题

197

帖子

1465

积分

金牌会员

Rank: 6Rank: 6

积分
1465
金钱
1268
HASS币
0
发表于 2022-11-9 09:46:27 | 显示全部楼层
2022-11-09 09:39:24  [ERROR   ] ---- Webdriver quit abnormly, reason: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//li[@class='inline_block_fix zhanghu-full']//b[@class='cff8']"}
  (Session info: headless chrome=89.0.4389.114)
回复

使用道具 举报

18

主题

587

帖子

4283

积分

元老级技术达人

积分
4283
金钱
3661
HASS币
182
 楼主| 发表于 2022-11-9 09:58:36 | 显示全部楼层
459662146 发表于 2022-11-9 09:46
2022-11-09 09:39:24  [ERROR   ] ---- Webdriver quit abnormly, reason: Message: no such element: Unab ...

你把我上回给你的文件,在以下位置添加两行,再打个截屏看看,加载的如何

   
def _get_eletric_balance(self, driver):
        time.sleep(20) ###############添加此行
        driver.save_screenshot("screenshot.png")   ###############添加此行
        driver.find_element(By.XPATH,"//li[@class='inline_block_fix zhanghu-full']//b[@class='cff8']")
        time.sleep(5)
        for retry_times in range(0, RETRY_TIMES_LIMIT):
            electric_balance = driver.find_element(By.XPATH,"//li[@class='inline_block_fix zhanghu-full']//b[@class='cff8']").text
            if(not electric_balance.startswith("-")):
                break
            time.sleep(1)
        return float(electric_balance.replace("元",""))
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-22 18:54 , Processed in 0.109955 second(s), 30 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表