Skip to content

Commit

Permalink
修复了book118下载失败问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zhang@laptop committed Jun 27, 2020
1 parent 5efe991 commit 0bfd6c1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions book118.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ def download(url):
actions = ActionChains(driver)
actions.move_to_element(elem).perform()
img = elem.find_element_by_tag_name('img')
count = 0
while count < 10 and img.get_attribute('data-src') == None and img.get_attribute('src') == None:
count += 1
time.sleep(1)

img_url = img.get_attribute('src')
if img_url is None or not 'http' in img_url:
img_url = "http:" + img.get_attribute('data-src')
Expand Down

0 comments on commit 0bfd6c1

Please sign in to comment.