onenote_export
onenote_export copied to clipboard
KeyError: 'src'
KeyError: 'src'
error occurs when there's a broken image in the source page. Work around is to remove the broken images in Onenote.
Example of broken images in Onenote:
traceback:
Opening page 23 Pandas tutor
Got content of length 9236
parser.feed tag_match: '''<img alt="py_dogs_jupyter" />'''
127.0.0.1 - - [07/Jan/2022 17:04:15] "GET /getToken?code=M.R3_BAY.696ee4c3-cea4-f297-b772-56bf57d354b8&state=a6efcfda-9d5f-4e28-98dd-93b766dd6b55 HTTP/1.1" 500 -
Traceback (most recent call last):
File "C:\ProgramData\scoop\apps\miniconda3\4.10.3\Lib\site-packages\flask\app.py", line 2091, in __call__
return self.wsgi_app(environ, start_response)
File "C:\ProgramData\scoop\apps\miniconda3\4.10.3\Lib\site-packages\flask\app.py", line 2076, in wsgi_app
response = self.handle_exception(e)
File "C:\ProgramData\scoop\apps\miniconda3\4.10.3\Lib\site-packages\flask\app.py", line 2073, in wsgi_app
response = self.full_dispatch_request()
File "C:\ProgramData\scoop\apps\miniconda3\4.10.3\Lib\site-packages\flask\app.py", line 1518, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\ProgramData\scoop\apps\miniconda3\4.10.3\Lib\site-packages\flask\app.py", line 1516, in full_dispatch_request
rv = self.dispatch_request()
File "C:\ProgramData\scoop\apps\miniconda3\4.10.3\Lib\site-packages\flask\app.py", line 1502, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "C:\Users\Matt\code\onenote_export\onenote_export.py", line 240, in main_logic
download_notebooks(graph_client, app.config['output_path'], app.config['select_path'], indent=0)
File "C:\Users\Matt\code\onenote_export\onenote_export.py", line 179, in download_notebooks
download_sections(graph_client, sections, path / nb_name, select, indent=indent + 1)
File "C:\Users\Matt\code\onenote_export\onenote_export.py", line 200, in download_sections
download_pages(graph_client, pages, path / sec_name, select, indent=indent + 1)
File "C:\Users\Matt\code\onenote_export\onenote_export.py", line 216, in download_pages
download_page(graph_client, page['contentUrl'], page_dir, indent=indent + 1)
File "C:\Users\Matt\code\onenote_export\onenote_export.py", line 229, in download_page
content = download_attachments(graph_client, content, path, indent=indent)
File "C:\Users\Matt\code\onenote_export\onenote_export.py", line 150, in download_attachments
content = re.sub(r"<img .*?\/>", download_image, content, flags=re.DOTALL)
File "C:\ProgramData\scoop\apps\miniconda3\4.10.3\Lib\re.py", line 210, in sub
return _compile(pattern, flags).sub(repl, string, count)
File "C:\Users\Matt\code\onenote_export\onenote_export.py", line 113, in download_image
image_url = props.get('data-fullres-src', props['src'])
KeyError: 'src'