From 8dc7cfa21be8a59c9071d0393e22e569593d7dfc Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Tue, 10 Nov 2020 20:23:34 -0800 Subject: [PATCH] Use requests.Session for embedded images. --- voussoir.net/writing/vmarkdown.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/voussoir.net/writing/vmarkdown.py b/voussoir.net/writing/vmarkdown.py index d36693c..574a007 100644 --- a/voussoir.net/writing/vmarkdown.py +++ b/voussoir.net/writing/vmarkdown.py @@ -41,6 +41,8 @@ HTML_TEMPLATE = ''' SLUG_CHARACTERS = string.ascii_lowercase + string.digits + '_' +session = requests.Session() + class SyntaxHighlighting: def block_code(self, text, lang): @@ -376,7 +378,7 @@ def embed_images(soup, cache=None): if cache.get(src) is None: print('Fetching %s' % src) if src.startswith('https://') or src.startswith('http://'): - response = requests.get(src) + response = session.get(src) response.raise_for_status() data = response.content else: