xuzhengyi1995 / Manga_downloader

A Manga download framework using selenium.
635 stars 58 forks source link

fix: Get hidden page counter #161

Closed jubame closed 6 months ago

jubame commented 6 months ago

Site: BookWalker JP OS: Arch Linux Chromium version: 123.0.6312.58

I am getting this error:

[INFO](root) 2024-03-21 11:24:55 : Start download...
[ERROR](root) 2024-03-21 11:24:56 : Something wrong or download finished,Please check the error.png to see the web page.
Normally, you should logout and login, then renew the cookies to solve this problem.
[ERROR](root) 2024-03-21 11:24:56 : list index out of range

This is a traceback:

Traceback (most recent call last):
  File "[...]/Manga_downloader/downloader.py", line XXX, in download_book
    page_count = self.actions_class.get_sum_page_count(driver)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "[...]/Manga_downloader/website_actions/bookwalker_jp_actions.py", line XX, in get_sum_page_count
    print(int(str(driver.find_element(By.ID, 'pageSliderCounter').get_attribute('textContent')).split('/')[1]))
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

error.png shows a page from the manga I want to download, so it is not an authentication problem. I have noticed that there is a EU GDPR cookie banner at the bottom:

error_image_no_page_slider

After further debugging, it seems that the page count string is empty. It does not appear in the image above. However, it is there, just hidden. Using .get_attribute('textContent') instead of .text seems to fix this.