|
如以下錯誤訊息,程式檢查無誤,請問錯在何處?
錯誤停在 src=item.select('a img')[0]["src"]
請輸入要下載的分類:1 下載的分類編號:1 分類名稱:文學小說 https://www.books.com.tw/web/books_nbtopm_01/?o=1&v=1 共有 8 頁 第 1 頁 https://www.books.com.tw/web/books_nbtopm_01/?o=1&v=1&page=1 --------------------------------------------------------------------------- KeyError Traceback (most recent call last) <ipython-input-5-8f9971c22da3> in showkind(url, kind) 10 print("第",page,"頁", pageurl) ---> 11 showpage(pageurl, kind) 12 except: #沒有分頁的處理
5 frames KeyError: 'src'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/bs4/element.py in __getitem__(self, key) 1533 """tag[key] returns the value of the 'key' attribute for the Tag, 1534 and throws an exception if it's not there.""" -> 1535 return self.attrs[key] 1536 1537 def __iter__(self):
KeyError: 'src' |